set value of input field by type and placeholder name from javascript table jquery -
i have table dynamically generated bootstrap , contains search field filter results. input search field generated such
html
<input class="form-control" type="text" placeholder="search" >
jquery
$(document).ready(function() { $('input[type="text"][placeholder="search"]').val("test"); });
i tried adding form-control
, did not work well.
$('input[class="form-control"][type="text"][placeholder="search"]').val("test");
this jfiddle works should, suspecting dynamic loading of search field bootstrap table not catching it.
after looking @ github source code here: https://github.com/wenzhixin/bootstrap-table/blob/master/src/bootstrap-table.js, found line 836 interesting, seems triggering search update on search text box keyup
event so...
settimeout(function() { $('input[type="text"][placeholder="search"]') .val("bootstrap") .trigger('keyup'); },0);
and ouila!
see example: http://jsfiddle.net/jchandra/s6g3r786/
Comments
Post a Comment