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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -