php - Accesing the id attribute of the select tag from jquery -
i looking way access id attribute of select tag jquery.
say have select tag on form : form.php
<select id="testid"> <option value="1">1</option> <option value="2">2</option> </select>
from jquery can access option value $(this).attr("value")
. $(this).attr("id")
gets undefined.
by giving option tag id attribute values works. but, there way around access id of select tag thru $(this)
object
thanks help
if trying within change
event of select
like:
$('select').change(function() { // here 'this' point select console.log( $(this)[0].id ); //or console.log(this.id); })
but $(this).attr('id')
should work.
if $(this)
point option
try
$('select').has(this).attr('id');
or
$(this).parent('select').attr('id');
Comments
Post a Comment