javascript - Selecting button with specific text only to activate on click event -
i have row of buttons difference between them inner text:
<a href="#contact" class="btn btn-large btn-info" data-toggle="tab">text1</a> <a href="#contact" class="btn btn-large btn-info" data-toggle="tab">text2</a> <a href="#contact" class="btn btn-large btn-info" data-toggle="tab">text3</a>
i want activate script when button 'text3' pushed . tried following works buttons not 'text3'.
$(function(){ $('a.btn[text()="text3"]').click(function(){ console.log(id); // action here }); });
how can fix this?
you can use :contains selector bind event handler specific anchor contains text
$('a.btn:contains(text3)').click(function(){ ...
Comments
Post a Comment