jQuery if Element has an ID?

How would I select elements that have any ID? For example:

if ($(.parent a).hasId()) {
    * then do something here *
}

I, by no means, am a master at jQuery.

View More Answer And Comment : Stackoverflow


Top Answer 1

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

Top Answer 2

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

Top Answer 3

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

Top Answer 4

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

Top Answer 5

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

Top Answer 6

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

Top Answer 7

Pure js approach:

var elem = document.getElementsByClassName(parent);
alert(elem0.hasAttribute(id));

JsFiddle Demo

View More Answer And Comment : Stackoverflow

Hive and Hadoop version

How can I find which Hive version I am using from the command prompt. Below is the details- I am using Putty to connect to hive table and access records in the tables. So what I did is- I opened [Read More...]

Null values found

I want to insert a not null value. This is a example: create table time( a varchar2(9), b varchar2(9), c varchar2(9)); table create insert into time (a,c) values ('qq','ee'); table altered When [Read More...]

Project help: underscore template

I have a project that requires me to use underscore templating. The app is suppose to get a recipe from an API and render it to the page. If the user likes the recipe, they will be able to save it [Read More...]

Angular jsonp is not workin

I'm trying to making jsonp call using below code but doesn't seems to be working for me. Code var url = 'http://z:15957/Category/Categories?callback=JSON_CALLBACK'; $http.jsonp(url).success(function [Read More...]

Informix: Date-Time conversion

I am getting lost and nuts with the DATETIME in Informix.I have two problems which I can hardly solve: I have a DATETIME column (e.g. starttime) which I need to convert into an int value, e.g. [Read More...]

Integrate linphone into iOS

I am trying to add linphone lib to my existing iOS app, but it fails to build My process: Added all the required frame works in my existing project. Copied all lib from [Read More...]

Kernel32.dll missing in QT

First of all thanks to those who will guide or give me a hint on my submitted issue. I am using QT4.7.4 (32bit). The problem is my QT creator can build some example project on QT but some aren't. If [Read More...]

Java Programming Guidelines

What Java Programming Guidelines you are using? I know that the most common is the one provided by Sun (http://java.sun.com/docs/codeconv/) but I would like to know if there are other market [Read More...]