javascript - js - check if same class elements have id -


i have 2 input tags:

<input type="text" class="maintext" id="input"> <input type="text" class="maintext"> 

i need set id input tag don't have id, may jquery like:

if(input tag has no id){     $(".maintext").attr("id", "someinput"); } 

how find non id input?

use magic of jquery selectors:

$('.maintext:not([id])').prop('id', 'someinput'); 

it select elements .maintext class :not have attribute [id].


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -