Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used the following code for changing the content of a style..
JavaScript
$("#Button1").click(function () {

          var str="12";
          if ($('#additionalStyles').length)
          {
              $('#additionalStyles').remove();
          }
          else
          {
              $('head').append('<style id="additionalStyles">.noti_bubble:before{color: yellow; content:'"+str+"''';}</style>');


          }

          });


The actual css code is ......

CSS
.noti_bubble:before{
    position:absolute;
    padding:1px 2px 1px 2px;
    background-color:red;
    content:"5";
    color:white;
    font-weight:bold;
    height : 11px;
    width: 15px;
}

The jquery changes the colour to yellow. but not change the content from 5 to 12....
pls help me....
Posted
Updated 29-Oct-14 0:12am
v2

properly pairing of ' and ", try this:
$('head').append('<style id="additionalStyles">.noti_bubble:before{color: yellow; content:"'+str+'";}</style>');
 
Share this answer
 
Comments
Nijisha Kc 30-Oct-14 1:52am    
i have tried this.but...
Peter Leow 30-Oct-14 3:34am    
Seeing is believing:
http://jsfiddle.net/uqf02522/
Nijisha Kc 30-Oct-14 4:26am    
ys. its worked. is this a temporary change?
Try this.
Note: haven't tested but hope this works :)

C#
$("#Button1").click(function () {

           var str="12";
           if ($('#additionalStyles').length)
           {
               $('#additionalStyles').remove();
           }
           else
           {
               $('head').append("<style id='additionalStyles'>.noti_bubble:before{color: yellow; content:'"+str+"''';}</style>");


           }

           });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900