Finding title in content using contains()
Is it possible to do: if first word in #title appears anywhere in #content than change color of #title to green? I tried an if statement but Im not sure whats going on there. Also im trying it with one line of jquery but Im getting lost in the stacking of methods/selectors. I doubt I can do it with just one line of jquery.
- <p id='title'>
- paragraph
- </p>
- <p id='content'>
- this is a paragraph
- </p>
- $("#content * :contains(#title.text())").css('color','green');
- //---OR---
- //(below I'm only trying to see if I can atleast get x and z to return true- which I cannot.)
- var x = $('#title').text();
- var z = 'paragraph';
- if (x === z){
- alert(x);
- };