Assign an ID to the search input

Assign an ID to the search input

fangyfangy Posts: 2Questions: 1Answers: 0

Hello,
i'm unable to assign via Jquery an ID to the input search ( i neet to get the value for php use).

$('#tabella_filter label input').on("focus", function(event){
$('#tabella_filter label input').attr('id', 'cerca');

});

this doesnn't work.
Some suggesions?

thanks in advance

Answers

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    You want to assign an id on focus? Unusual, but fair enough :-). The code you have should work, although you could do this.setAttribute( 'id', 'cerca' ); in the event handler.

    Allan

  • fangyfangy Posts: 2Questions: 1Answers: 0

    well, i've tried to assign even without the binding 'on', but without success. :(
    and again, it doesn't works :(

    To tell the truth, the code

    $ ('# tabella_filter label input').attr ('id', 'search');

    if entered from the console after page loading, it works! but not if executed in page.

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Seems to work entirely as expected for me: http://live.datatables.net/wojumuva/1/edit .

    Please link to a test case showing the issue.

    Allan

This discussion has been closed.