$( "p[id*='baliseP']" ).click(function() { console.log( $(this).attr('id') ); alert($(this).text()); } );