<div id="id" class="div-style"><img id="id" class="img-style"></div>
I would like to use the id attribute as a way for jQuery to select the element, and the class attribute for CSS to style it.
My guess for jQuery selector ran thusly:
$("#id .div-class")
and
$("#id .img-class")
This returns the error “Selector expected”
Using
and
attempts to select descendent elements with CSS class ‘div-class’ and ‘img-class’ of the element with id
id, respectively, which won’t return anything. Selecting an element by id is the fastest way and you wouldn’t need to specify the CSS class if using id, since the HTML specification states that elements ids should be unique within a page. So, using justwill select the div with id
id. Now what would you like to do with the element?