How can I put a value(like: 5 开发者_运维技巧or Etc.) Inside the INPUT => NAME
on the checkbox(...name="checkbox[HERE][]"...)
after click on button by jQuery?
Html:
<input type="checkbox" name="checkbox[/*HERE*/][]">
Please give me an example in http://jsfiddle.net/ .
Use the attr()
method on the element.
$('input').attr('name','checkbox['+value+'][]');
js Fiddle Demo
use .prop
because node name is a property. http://api.jquery.com/prop/
$('input:button').click(function(){
$('input:checkbox').prop('name','checkbox['+10+'][]');
});
Assuming you only have one checkbox on the page:
$('some button selector').click(function(){
$('input[type=checkbox]').attr('name', 'some value');
});
精彩评论