JQuery :: Highlight Certain Text Strings?
Jul 3, 2010
What I want to do specifically is add a CSS class to strings that start with an @ symbol. I can't seem to find any examples online and I haven't had enough experience with jquery to figure this out on my own.
I want it to highlight either the first word only, or just the line that the @ symbol is found on.
View 8 Replies
ADVERTISEMENT
Dec 20, 2011
I have work thumbnails on one side (meals), ingredients on the other side, what I would like to do is:
1) If I hover over a meal, the ingredients used for that dish are highlighted on the left
2) If I hover over an ingredient, the dishes that used this ingredient are selected
I am just starting out in jQuery, can anyone give me some pointers.
View 5 Replies
View Related
Oct 15, 2010
I have spent the last week trying to figure out how to do the following: User types some text in a text box. The autocomplete queries a php script that returns JSON of matched values. I have got thedrop down list to show these values but I cannot for the life of me get the matched characters to turn bold. For example, if the user types in "rav" and my list contains:
RAVEN
RAVE
RAVEL
then I want it to appear as
RAVEN
RAVE
RAVEL
My current JS code is as follows (along with HTML):
$(function() {
$( "#query" ).autocomplete({
source: "get_json.php",
[code].....
View 6 Replies
View Related
Sep 10, 2010
Alright, I'm using a Rooh.It WordPress plugin right now, but I don't like the way they do it, so I want to write my own code to do something similar.
I want the user to be able to select the text they want to highlight, and the background color of that text changes to whatever color they have selected.
How can I do this in JavaScript?
View 4 Replies
View Related
Apr 21, 2011
Here's a sample form:
Code:
<form action="#" method="post">
Name:<br />
[code]...
View 3 Replies
View Related
Apr 21, 2011
Here's a sample form:
Code:
<form action="#" method="post">
Name:<br />
<input type="text" name="name" value="your name" /><br />
[Code].....
When you tab to a text input, the value gets highlighted. How can it be disabled?
View 7 Replies
View Related
Apr 21, 2011
Here's a sample form:
<form action="#" method="post">
Name:<br />
<input type="text" name="name" value="your name" /><br />
[code]....
View 1 Replies
View Related
Nov 10, 2010
function test() {
jQuery('select#Sum option[text$="test"]').each(function (i) {
this.style.backgroundColor = "#FFCCCC";
[code]....
View 2 Replies
View Related
Nov 9, 2010
I am attempting to manipulate a long text string with javascript. This text string may have one or more occurrences of a string which starts with a particular string and ends with another string. So, for example, text that starts with 'nam' and ends with 'sit' in this example:
Lorem ipsum dolor sit amet, consectetur adipiscing elit nam aliquam leo sit amet nibh tincidunt ultricies. Nullam nam feugiat velit sit amet dui scelerisque id ornare nulla ultricies.
I want to prepend another string before the nam and append another after the sitt, to give me:
Lorem ipsum dolor sit amet, consectetur adipiscing elit before nam aliquam leo sit after amet nibh tincidunt ultricies. Nullam before nam feugiat velit sit after amet dui scelerisque id ornare nulla ultricies.
I think the way to do this is via RegExp, but I'm insufficiently familiar with this to know how to write the expression.
View 11 Replies
View Related
Nov 26, 2005
When I enter a text string for a document.write method it works AS LONG AS the text is all on one line. This is true in assigning a text string to a variable also. I like to write my documents so that they are readable. How do I get the text to be on multiple lines without getting the "unterminated string" error?
View 3 Replies
View Related
Jul 23, 2005
Is it possible, using Javascript, to highlight (in yellow..) all the occurrences of "number: [0-9]+" (regex) of the document?
View 5 Replies
View Related
Oct 20, 2006
On click of a link , the contents get displayed in an iframe. Is there a way to search some text in the content displayed in the iframe and highlight it.
View 1 Replies
View Related
Jul 14, 2007
Is there a way to selectively highlight text in an OverLib popup? I'd
like to be able to make some text stand out from the rest of the text
that is displayed.
I tried using a one-cell table with background set to yellow, but that
caused the popup not to work at all (this might be a syntax problem -
I haven't been able to find any syntax examples for putting a table
inside an OverLib call)
View 5 Replies
View Related
Oct 25, 2006
I dont know how to make the function, i would like it so that when the user enters the text it searchs the text on the page and hilites behind the text yellow. So its a bit like a "find" function that hilites behind the word that it is asked to find.
View 2 Replies
View Related
May 26, 2009
I have a list of 400+ names I am getting from a mysql database.They are listed out in a table.I would like to have a text box where once you start typing,the more I type the less matches come about
View 6 Replies
View Related
Oct 6, 2011
I have a webpage that has a texbox with states that the user can select using ajax auto complete extender. The states are separated by the ; character. Is it possible to select everything between the ; characters if a user clicks on any of the text between them.
[Code]...
View 1 Replies
View Related
May 11, 2010
I've tried to do it using the funciton below, it cycles through allright, but only highlights each field whilst it is in focus, then loses it when it moves to the next field. The result is that only the last text/textarea within the form is highlighted. My aim is to highlight all fields for subsequent spell checking.
View 13 Replies
View Related
Nov 22, 2002
Highlight a portion of the text and you can search it on the major search engines. The search box can also be used as a conventional search box too....
View 3 Replies
View Related
Dec 20, 2007
I need to highlight words in text inside iFrame (target page is actually from another site). Code:
Is it possible to force this script to highlight text inside iFrame? Or probably there is another solution exists?
View 1 Replies
View Related
Dec 11, 2010
I'm working on an educational website for reading strategies where I would like to have the possibilty for the user to highlight text and the possibilty to check their highlighted answers.User task: Mark all the cause and effect connectors (because, so, therefore etc) in the text.Now I want the user to take the mouse and go over the text and mark all these connectors in the text. After marking the entire text the user will get feedback for his correct and incorrect answers and a possibilty to correct his mistakes.If the user marks in the sentence "He got hurt, because he fell of his bike." the word 'because' I would like somewhere else on the page be written that he did this correctly. If he would mark the word 'hurt' I would like the user to get a feedback saying that this answer is incorrect.Is this possible with simple html or do I need something else. If I need something else what do I need and maybe there is already a ready to use script for this.
View 2 Replies
View Related
Jun 5, 2011
Got this below code for a page im working on, what you'll notice is that when you hover over 'order' a sub menu appears,
How do I make the 'order' remain highlight while Im hovering over the sub menus.
View 2 Replies
View Related
Jul 23, 2005
I'm working on a JSP application, and wish to define a text-field so
that it becomes marked (highligted) when it obtains focus.
I've tried giving the text-field a value when it obtains focus, but
the value is not marked. So if i wish to alter the value, I have to
manually delete the given 'onFocus' value before I set a new value.
<INPUT TYPE=TEXT NAME=test size=30 want this
to be highlighted!'">
I'm missing something to highlight the text-field text in the code
above.
View 1 Replies
View Related
Jul 9, 2002
People have complained that window.find() doesn't work, and everyone knows Gecko doesn't support IE's proprietary TextRange object, some have assumed you can't do this in Gecko.
On the contrary though:
Node.prototype.findTextMatches = [];
Node.prototype.findText = function(query, ignoreCase) {
this.findTextMatches.length = 0;
if (ignoreCase)
query = query.toLowerCase();
var tw = this.ownerDocument.createTreeWalker(this, NodeFilter.SHOW_TEXT, { acceptNode: function(node) {return NodeFilter['FILTER_' + (RegExp(query, (ignoreCase ? 'i' : '')).test(node.nodeValue) ? 'ACCEPT' : 'REJECT')] } }, true);
var offsets = [];
offsets[-1] = query.length * -1;
var totalMatches, trueOffsetDiff;
var range = this.ownerDocument.createRange();
while (tw.nextNode()) {
totalMatches = tw.currentNode.nodeValue.split(RegExp(query, (ignoreCase ? 'i' : ''))).length - 1;
for (var i = 0; i < totalMatches; i++) {
trueOffsetDiff = offsets[offsets.length - 1] + query.length;
offsets[offsets.length] = tw.currentNode.nodeValue.substr(trueOffsetDiff)[ignoreCase ? 'toLowerCase' : 'toString']().indexOf(query) + trueOffsetDiff;
range.selectNode(tw.currentNode);
range.setStart(tw.currentNode, offsets[offsets.length - 1]);
range.setEnd(tw.currentNode, range.startOffset + query.length);
this.findTextMatches[this.findTextMatches.length] = range.cloneRange();
}
offsets.length = 0;
}
return (tw.currentNode != this);
}
Node.prototype.highlightText = function() {
if (this.findTextMatches.length > 0) {
with (window.getSelection()) {
removeAllRanges();
addRange(this.findTextMatches.shift());
}
return true;
}
else
return false;
}
To search all text in the body, ignoring case, you'd go like:
document.body.findText('search query', true);
That loads up an array full of ranges selecting the text into document.body.findTextMatches.
To selectively highlight next occurences after executing findText:
document.body.highlightText();
// highlights first occurence
document.body.highlightText();
// removes previous selection, highlights second occurrence
// etc
Just calling that method over and over will successfully highlight instances. It returns true if it highlighted something, false otherwise,
Also, since I prototyped Node, it works not just in HTML documents, but can work in XML documents too.
Calling document.findText in an HTMLDocument may cause interesting results, as it searches through all the nodes, including <head>...
View 8 Replies
View Related
Sep 26, 2006
I have an input box of type text. It is a simple onclick text in the box and it becomes blank and you can enter stuff in.
<input type="text" name=number value=999 onFocus="this.value=" >
What I'm wondering is if it is possible that when clicked on a link, the text in the textbox becomes highlighted(background blue, text white)?
View 5 Replies
View Related
Apr 6, 2010
I am attempting to use JavaScript to 'highlight' text by changing it's background color:
In JavaScript:
This produces no effect. I also have an onClick event in the same div, can I not have onClick and onMouseOver together?
View 3 Replies
View Related
Nov 20, 2011
I have several sections in a text, and I would like to highlight each section as mouse rolls over.. I've tried to span the fragments of text but it doesn't work in my jsp.
View 4 Replies
View Related