1 (edited by LordTimon 2012-04-10 10:55:31 PM)

Topic: How get the attribute's value?

Hi all.
I just started to learn xajax.
Sorry if this question has already been but I have not found an answer.
I am interested in the following : is it possible get the attribute's value?
For example :
img id="image1" height="100" onclick="xajax_bigimages('image1');" src="image/VS-1017.jpg"

I need to get the attribute value height how to do it?

2 (edited by romacron 2012-04-11 11:08:32 AM)

Re: How get the attribute's value?

Hello LordTimon,

yes its possible.
The full written statement to get an element by Id
var theElement = xajax.tools.$('image1')
with the shortener
var theElement = xjx.$('image1') without the "a" in xajax. this triggers exactly to xajax.tools
if the DOM-id 'image1' not found, the method returns false.

to prevents from errors during an element does not exists use one of the expressions above.
Thats  more save as document.getElementById('image1');

if(ele=xajax.$('image1'))return ele.height

fully written to prevents from "undefined" properties like this
    //save getting height of the image src attribute
        if('undefined' != typeof ele.height)
            return alert(ele.heigth);  //attribute exists
            return alert('there is no height attribute'); //attribute doesn't exists

Re: How get the attribute's value?

Thank you,  romacron. smile