This is simple and no need to write post for it. You may feel same right? But, this is the question I received from almost 10 people till now. So, I thought of writing a post on it. So that, it may help people who are looking for the same through out the world.
By default JQuery returns object when you declare $("$id") or $(".class"). If you write code for it as below, then that's wrong.
- if($("#id") != null)
- {
- //Write code if the object is not null
- }
- if($(".class") != null)
- {
- //Write code if the object is not null
- }
- if($("#id").length > 0)
- {
- //Write code if the object is not null
- }
- if($(".class").length > 0)
- {
- //Write code if the object is not null
- }
Hope, this solved your problem and this is a new tip for today. Is this helpful?
Комментариев нет:
Отправить комментарий