The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Searching for a “string” with jQuery?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #38159

    First off, i wanted to just say thanks to the people who are reading my posts and helping me with my syntax and logic problems. This has been a really great community to share code and learn from people.

    Now with that said…

    My code here searches an html element for what contains a string. Once the string is matched than the attributes are applied. My only problem, i feel like this code isnt meeting its true potential of being EASY! And second, if search my element for lets say, “i” than all words with i in it have attributes applied. I want to just target a single i if it is alone ya know.

    var newText = $("pre").text().split(" ").join(" ");
    newText = "
    " + newText + "";

    $("pre").html( newText )
    .find(":contains(' anyword ')")
    .css({"font-style":"italic", "font-weight":"bolder"});

    If you say that im reinventing the wheel and just use a plugin, well lol, im mainly doing this kind of thing so i can learn, get used to the syntax, and just have fun with it. jQuery has turned my world around and i cant soak up enough info.

    Thanks in advance, in case i dont respond quick enough, been super D duper busy…

    EDIT: i was just thinking that maybe regular expressions might do the trick with some white space checking, anyone know how to implement? Declare the regex as a var and test the var against what im searching for?

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.