jquery - Apply an effect to many IDs in a page -


i using loading effect in button (bootstrap v.3) works fine.

<a href="#" class="btn  btn-primary" role="button" id="fat-btn" >read</a> 

and script

       $('#fat-btn').click(function () {             var btn = $(this)             btn.button('loading')             settimeout(function () {                 btn.button('reset')             }, 9000)                     }); 

this works fine! applied first button in page. can do, apply effect more buttons? thought type similar scripts different selectors. not convenient, (if have 20 buttons, type 20 different selectors??)

use class selector instead of id selector , assign same class buttons have.

$('.btn-primary').click(function () {     var btn = $(this);     btn.button('loading');     settimeout(function () {        btn.button('reset');     }, 9000);             }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -