Welcome Guest, Not a member yet? Register   Sign In
getElemntbyid returns undefined value
#7

(This post was last modified: 08-28-2018, 04:54 AM by kaitenz. Edit Reason: added info )

(08-27-2018, 11:36 PM)Vitaly83 Wrote: Using of jQuery and other libs will not help if the element with this ID is not exists.

Using jQuery, you can check whether the element exist.

Code:
if($('#texttwo_'+rowid).length)
{
    // Do code
}


I always do that check when I'm using DataTables or some other JS plugins. I first check if that table exists, then if yes, I initialize DT to that table. It always works for me.

Edit:
By the way, the code above will only return 0 or 1 (true or false equivalents) so no need to do if($('#texttwo_'+rowid).length > 0)
Correct me if I'm wrong.
Reply


Messages In This Thread
RE: getElemntbyid returns undefined value - by kaitenz - 08-28-2018, 04:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB