I’m trying to use a VARIABLE as a ATTRIBUTE value…
I have :
var text = "Hello!";
and the HTML is :
<li class="pro" id="text"> —> (I want the attribute ID to equals the TEXT variable)
How can I make this work?
Thank you
EDIT
I will be more specific in my question.
Here’s what I really have :
<li class="product" name="RD-101" price="18" minimum="4" gap="4">
<a class="product-image fancybox" href="images/product_big.jpg" title="Picture 4">
<img src="images/product_2.png" alt="Preview"/>
<div class="text-overlay">
<p class="product-heading">Description</p>
Enseignes résidentielles imprimées sur 2 panneaux 4 mm 36” x 24” collés dos à dos.
</div>
</a>
<p class="product-heading">RD-101 (Simple)</p>
<a href="#" id="test" class="product-buy">Ajouter au panier</a>
<p class="product-meta">Double de pareterre 32x24</p>
<div class="product-price">18<span class="product-currency">$</span></div>
</li>
As you can see I use custom attributes that are set in my Javascript code.
I want to know how to set (for instance)…the PRICE attribute to a VARIABLE VALUE instead of the number “18” like it is right now in what I pasted up there.
I was thinking of something like –>
<li class="product" name="RD-101" price="MY_VARIABLE_HERE" minimum="4" gap="4">
Use
$("li.pro").attr('id', text);with jQueryRemember attribute
nameis not valid for a<li>EDIT :
With no jQuery, this code add a
price(not valid) attribute to alllielements–
Last thing, we said
pricewasn’t a valid attribute.If you want your HTML doc to be valid, have a look here