jquery - Find tags with no classes and add a class -


i need jquery add class form element has no class allready. made function, hasnoclass.

is possible in real life? pseudo code: add class "classless" form tag jquery("form").hasnoclass().addclass("gotclass");

alternatively can done "add class 3rd form start tag on page. no clue how either, there may position or count function pseudo code: add class third form tag: jquery("form").postition("3").addclass("gotclass");

wow! 2 questions! need 1 answer on both appreciated sake of knowing , maybe future use.

br. anders

this should do:

$('*:not([class])') 

you'd able do

$('*:not([class])').addclass('gotclass'); 

or

$('*:not([class])').eq(3).addclass('gotclass'); 

to clarify: selector matches elements, *, not within scope: "any element attribute, [,], class"


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -