javascript - Any way to save a property in :before / :after using jquery -



javascript - Any way to save a property in :before / :after using jquery -

question: know can't access :before , :after selectors via jquery writing code this. because :before / :after not part of dom.

$(document).ready(function(e){ var beforebg = $('.someclass:before').css('background-color'); })

is there way can save value in variable or there isn't way @ all? know there methods discussed here on this post says create class , define :before / :after on class , toggle class using jquery. not requirement here. need value stored in variable utilize in script.

update: why need stored in vairable? please refer this question here know doing. when able store value in variable, i'd able iterate on dom using each() , i'll able add together specific class element has background-color equal color stored in variable (beforebg in case).

update: check css code

.service-content:after { background: none repeat scroll 0 0 #eb2c33; border-radius: 100%; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.09); content: ""; height: 8px; left: 274px; margin-top: -58px; position: absolute; top: 50%; width: 8px; z-index: 3; }

so can store value "background" color value ( "#eb2c33" in case ) in variable beforebg?

there no psudeo selectors :before or :after in jquery. if want seek way

$(document).ready(function(e){ var beforebg = $('.someclass').addclass('sample'); });

in style sheet

.someclass.sample:before, .someclass.sample:after { background: #ccc; }

javascript jquery

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -