• Resolved michalrama

    (@michalrama)


    Hello,

    This is more of a code level question. I need to replace specific text.

    It is the same on all pages, it is a <span> element and its parent element <a> always has the same URL. It could certainly be used to easily find this element.

    How can I do this easily using JQuery please?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Something like:
    $('a[href="https://example.com"] span').html("my new content");
    (untested)

    It’d be a lot easier if the span element had a unique identifying class name.

    Having jQuery search through content for something in particular isn’t very efficient. Ideally the correct content would have been saved to start with. It’d be better to do a search and replace in the DB once than to do it every time a page is served.

    Thread Starter michalrama

    (@michalrama)

    Hello @bcworkz

    Thank you. It works. To be precise, these are breadcrumbs that are generated by the theme itself.

    And the home page is showing as HOME not DOM?.

    So thanks again, this code works, but still I wrote to the theme support if it is possible to generate it directly in the correct language.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Replacing specific text with something else using JQuery.’ is closed to new replies.