You cannot access an element with $(this) at event binding like this:
<select onclick="fun()">
....
fun()
{
$(this).each(function ( )
{
.....
........
Reason : It works in iteration to refer to the element
$("select#"+id+" option:selected").each(function ( )
{
if($(this).val() =="Defined" )
{
str=str+$(this).val();
.............................
or you can also use that element at finction calling like this.....
<select id="xyz" onclick="fun(this.id)">
<select onclick="fun()">
....
fun()
{
$(this).each(function ( )
{
.....
........
Reason : It works in iteration to refer to the element
$("select#"+id+" option:selected").each(function ( )
{
if($(this).val() =="Defined" )
{
str=str+$(this).val();
.............................
or you can also use that element at finction calling like this.....
<select id="xyz" onclick="fun(this.id)">
No comments:
Post a Comment