Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to add a dropdown value to a attribute in the table below. But it doesn't seem to work using the .attr() from jQuery

This is the jquery:

$("#datasize").change(function(){ 
        var element = $(this).find('option:selected'); 
        var myTag = element.val(); 

        $('#filterTable1').attr('data-page-size' , myTag); 
    }); 

This is the html:

    <select id="datasize">
        <option value="10">My option</option>
        <option value="20">My other option</option>
    </select>
    <table class="footable" data-page-size="" id="filterTable1">
        <thead>
          <tbody>
          </tbody>
        </thead>
   </table>

Any help would be appreciated!

share|improve this question
1  
It does work already - jsfiddle.net/jxXsN –  user3237539 Jun 4 '13 at 11:58
 
It does work... It's a library that's conflicting :) Thanks –  msbodetti Jun 4 '13 at 12:07
add comment

1 Answer

up vote 1 down vote accepted
$(function() {
    $("#datasize").on('change', function(){ 
        $('#filterTable1').attr('data-page-size' , this.value); 
    });
});
share|improve this answer
 
It does work... It's a library that's conflicting :) Thanks –  msbodetti Jun 4 '13 at 12:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.