I have small javascript file that show two images, i want to set the size of those two images, for e.g. in html i will need to use this: width="xx" height="xx" what about javascript? here is my code: $().checkbox({checked: "/img/checked.jpg", unchecked: "/img/unchecked.jpg"}) Code (markup):
As you are using jquery thats very simple. You can either set the width and height attribute or assign some css to the image. Have a look at the jquery methods attr and css
you can get the element from the page first by id like : $('XXX').width= ... , height = ... using jQuery ( which u r ) , is very simpler instead of getElementByID or other ways like document.images
hi i think that using jquery you have to do like this $('image element selector').width(100).height(200); ///you can do this as width and height are functions and they return the jquery object if you want to use the jquery css function you have to do this $('image element selector').css({width:"100px",height:"200px"}); hope it helps John
if you are not familiar with jQuery selectors I suggest reading the online documentation on the jQuery site as a crash course in jQuery selectors: - selectors are ways of identifying DOM elements - jQuery selectors are similar to CSS selectors (probably not very helpful info for you) simple selectors: .cssClassName - selects elements that have a specific class or #id - selects the element with the specified id or tagname - selects all element having the specific tagname for example if you have something like .... <div class='imageHolder'> <img src='something.jpg' id='myImage'/> </div> ... $('img') - will select (tagname selector) all the images in the document so every transformation you apply will reflect on all images; in our case if there arent any images in the document it will select the on image $('.imageHolder') - will select all the elements having the class name imageHolder; in our case the div $('#myImage') - will select the image with the id myImage; in our case the one image you can also combine selectors $('img#myImage') - select all the img elements having the id myImage $('div.imageHolder') - select all the div elements that have the classname imageHolder also there are more advanced selectors like $('div.imageHolder > img#myImage') - select the div with the classname imageHolder and then select the direct child img tag with the id myImage