Add Attribute Jquery data type string + variable -


i have variable called vp_height want put data variable, putting this, prompt error.

var vp_height = viewportsize.getheight();  //sample data $(".carol").attr({     "data-" + vp_height : "width:50%;" }); 

here's error

enter image description here

it should in frontend. (visual presentation)

<div class="staff-container carol" data-667="width:50%;"></div> 

any solution stuff?

you can use:

$(".carol").attr("data-" + vp_height, "width:50%;"); 

fiddle demo


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -