How can I change the text of an element but maintain CSS styling in Jquery?

Takeshi Patterson

I am trying to replace the text of a list element and maintain the stylying of the original class, however, when I replace it overwrites the CSS. When I try add new styling to it it doesn't seem to work. I may be mis-understanding the html() function - can it have styling applied to it?

$('#listElement>li:eq(1)').html('replacement text').addClass('.progressStep')

$('.progressStep').css({
   'width': '140px',
   'display': 'block',
   'margin': '10px 0 0 -60px',
   'color': '#c5c5c5'
})
Milind Anantwar

You have passed .progressStep as argument to .addClass(). which is adding class .progressStep and not progressStep

You do not need to use class selector in .addClass() method. you should simply pass classname(s) as an argument. In current case, use addClass('progressStep') instead of addClass('.progressStep'):

$('#listElement>li:eq(1)').html('replacement text').addClass('progressStep')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I change the ckeditor iframe CSS styling

From Dev

How can I centralize this jquery styling colors into css?

From Dev

How can I centralize this jquery styling colors into css?

From Dev

How can I add styling to an element in React?

From Dev

How can I change the default styling for Jquery require_from_group method?

From Dev

On a CSS hover event, can I change the above div's styling?

From Dev

On a CSS hover event, can I change the above div's styling?

From Dev

How can I use JQuery to replace CSS background image and maintain gradient?

From Dev

How can i achieve the bootstrap styling effect for a simple select dropdown-Jquery/CSS

From Dev

How can I change the text of a button which is in class element?

From Dev

How can I change the offset parent of an absolutely positioned CSS element?

From Dev

How can I change CSS style, and focus on element as time goes by?

From Dev

How can I change the underline colour with the transition element in use? (CSS)

From Dev

How can I center text inside a div element using CSS

From Dev

PHP - How can i maintain value of a select element after a postback?

From Dev

PHP - How can i maintain value of a select element after a postback?

From Dev

How can I change the ID of a cloned element using jQuery?

From Dev

How can I change the ID of a cloned element using jQuery?

From Dev

Using jquery, how can I get this "inner text" of a li element?

From Dev

How can I change the styling of a progress bar on iOS using Ionic?

From Dev

How can I alert a text on input change? (jquery)

From Dev

How can I change the effect way on this jQuery iOS slider text?

From Dev

How can I alert a text on input change? (jquery)

From Dev

How can I get HAML syntax styling to work in Sublime Text?

From Dev

How can I change a css style for 'this' class using jquery?

From Dev

How can I use CSS styling in my GTK# application?

From Dev

How can I get more creative with styling in CSS

From Dev

How can I alter CSS styling for this carousel-title class?

From Dev

How can i add CSS styling to a asp.net listview?

Related Related

  1. 1

    How can I change the ckeditor iframe CSS styling

  2. 2

    How can I centralize this jquery styling colors into css?

  3. 3

    How can I centralize this jquery styling colors into css?

  4. 4

    How can I add styling to an element in React?

  5. 5

    How can I change the default styling for Jquery require_from_group method?

  6. 6

    On a CSS hover event, can I change the above div's styling?

  7. 7

    On a CSS hover event, can I change the above div's styling?

  8. 8

    How can I use JQuery to replace CSS background image and maintain gradient?

  9. 9

    How can i achieve the bootstrap styling effect for a simple select dropdown-Jquery/CSS

  10. 10

    How can I change the text of a button which is in class element?

  11. 11

    How can I change the offset parent of an absolutely positioned CSS element?

  12. 12

    How can I change CSS style, and focus on element as time goes by?

  13. 13

    How can I change the underline colour with the transition element in use? (CSS)

  14. 14

    How can I center text inside a div element using CSS

  15. 15

    PHP - How can i maintain value of a select element after a postback?

  16. 16

    PHP - How can i maintain value of a select element after a postback?

  17. 17

    How can I change the ID of a cloned element using jQuery?

  18. 18

    How can I change the ID of a cloned element using jQuery?

  19. 19

    Using jquery, how can I get this "inner text" of a li element?

  20. 20

    How can I change the styling of a progress bar on iOS using Ionic?

  21. 21

    How can I alert a text on input change? (jquery)

  22. 22

    How can I change the effect way on this jQuery iOS slider text?

  23. 23

    How can I alert a text on input change? (jquery)

  24. 24

    How can I get HAML syntax styling to work in Sublime Text?

  25. 25

    How can I change a css style for 'this' class using jquery?

  26. 26

    How can I use CSS styling in my GTK# application?

  27. 27

    How can I get more creative with styling in CSS

  28. 28

    How can I alter CSS styling for this carousel-title class?

  29. 29

    How can i add CSS styling to a asp.net listview?

HotTag

Archive