how to display image properties on page load
Question
Application Type
Reactive

Hi,

I am trying to Read image's style attribute [height & width]  value using jQuery. But when I run I get "Undefined". But if I call the same jQuery on Button click  I get exact value.  I want to display those values on my page ready. I tried on OnReady as well. 

Please help me here.

jQuery Code : 

$(document).ready(function(){
var imgH = $(".myClass img").css("height");
var imgW = $(".myClass img").css("width");
   

alert(imgH+ " " + imgW);
});


Thanks

Solution

Hi Khris,

Hope you are doing well.

First include jQuery in your module.
Then after, Select it in Screen where you are using jQuery.  

Now you can apply your jQuery code at OnReady event. 

Please check sample screen and OML-   imageSize  , I applied it OnReady.

Note- React uses virtual DOM to display the details and Jquery is used to manipulate the DOM. So if you are using Jquery with React then you will be basically manipulating the Virtual DOM which is not recommended. 

Hope this help,

Cheers.



ReactLab.oml

Solution

Hi Khris,

Hope you are doing well.

First include jQuery in your module.
Then after, Select it in Screen where you are using jQuery.  

Now you can apply your jQuery code at OnReady event. 

Please check sample screen and OML-   imageSize  , I applied it OnReady.

Note- React uses virtual DOM to display the details and Jquery is used to manipulate the DOM. So if you are using Jquery with React then you will be basically manipulating the Virtual DOM which is not recommended. 

Hope this help,

Cheers.



ReactLab.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.