This is my html code
<div class="class_test" id="id_test">
<h2>testing</h2>
<img/>
<div class="rightBox">
<h4>test</h4>
<p>test</p>
</div>
</div>
in javascript code, i want to select img to set it's src , height , width
$("#id_test > img").src = "blablabla.jpg";
$("#id_test > img").height = "100";
$("#id_test > img").width = "100";
but it doesn't work
Where did i miss it ?
Otherwise, how do i use the native javascript code without using jquery
document.getElementById("blabla")
i don't want to set the img ID
$("#id_test > img")is array like object . to access first you should use this way$("#id_test > img")[0].src.. or useattrwhich loop items and set properties .. in behind it's iterate elementsif ( $("#id_test > img").length > 0 ) { $("#id_test > img")[0].src = "blablabla.jpg" }.. check length is greater than 0 .. if you not pass correct selector query . it's length is 0$does not refer to jQuery. jQuery would never returnnull. If you want to use jQuery, make sure it's loaded.