mercredi 30 avril 2014

How to have JavaScript read a value appended with CSS at a given ID


Vote count:

0




Before I get started on this abnormally weird question, lemme just say that I have never heard of the following hack being applied let alone conventionally discussed with any web programmers I know, and this is merely out of curiosity in the event that I'm wrong in my hypothesis that it cannot be done.


That being said, here's my question:



Using a customized CSS based off of the latest Bootswatch version (actually using Cerulean theme), is it possible to append text between hidden p tags AND have JavaScript read the value appended properly?



Extra info: When hardcoding a value into the HTML, JavaScript has NO problem reading the value. When appending however (using #element:after for instance), JavaScript is passing a null value, I figure because the CSS loads after the JavaScript has already checked to see what value is at that particular element ID.


Example Code:


HTML



<div id="hiddenSecrets" style="display:none;">
<p id="valueOne"></p>
<p id="valueTwo"></p>
</div>


CSS



#valueOne:after { content:"2048"; }


JavaScript reads the ID "valueOne" to be null.


Any help is appreciated.


Thanks!



asked 42 secs ago






Aucun commentaire:

Enregistrer un commentaire