I've been searching but just can't seem to find a correct answer - or it might be me that can't figure out to ask the right question. Anyways, I've got html form with 4 sections each containing one input, one textarea, one input and one select - in that order. The thing is that I'd like to get the id of the select when I'm typing in information in the first input in the corresponding section. I'd like it to be dynamic using jQuery.
So when I enter text in input1, I'll get the id of select1.
How do I do this?
答案 0 :(得分:0)
without seeing your code it is impossible to adapt this to your situation, but just as a general guide line, you can use the .next()
method in jQuery, like this
$('input').keyup(function(){
var sel_id = $(this).next('select').attr('id');
alert(sel_id);
})