Sirdots
asked on
Search for a name in a div
I have this div in my html file. I want to be able to search for the name john bassey.
If the name is John bassey, I want a confirm popup to come up. If the user clicks on ok it should take the user to a new page and if cancel, nothing should happen
<div class="ContentLeft">
<h1 class="header">Employee profile - john bassey</h1>
</div>
How do I write this using jquery?
If the name is John bassey, I want a confirm popup to come up. If the user clicks on ok it should take the user to a new page and if cancel, nothing should happen
<div class="ContentLeft">
<h1 class="header">Employee profile - john bassey</h1>
</div>
How do I write this using jquery?
$(".ContentLeft:contains(j ohn bassey)").css("background","green") ;¿
or :
$(".ContentLeft:eq(0)").fi lter(funct ion() { return $(this).text().indexOf("jo hn bassey")>=0; }).css("background","green ");¿
http://jsfiddle.net/LZWRJ/1/
http://jsfiddle.net/LZWRJ/2/
or :
$(".ContentLeft:eq(0)").fi
http://jsfiddle.net/LZWRJ/1/
http://jsfiddle.net/LZWRJ/2/
dynamically :
var s = "john bassey"
//$(".ContentLeft:contains(" + s + ")").css("background","green");¿
// or
$(".ContentLeft:eq(0)").filter(function() { return $(this).text().indexOf(s)>=0; }).css("background","green");
ASKER
Thanks everyone for all your response. Here is what i want
1. search for john bassey.
2. if name john bassey is found, display a confirm popup box which says ok and cancel
3. if user clicks ok redirect to main.aspx else clear the popup box.
Am new to jquery. Am I able to store item 1 in a variable and then test if john bassey was found?
can I do a redirect to another page within jquery?
1. search for john bassey.
2. if name john bassey is found, display a confirm popup box which says ok and cancel
3. if user clicks ok redirect to main.aspx else clear the popup box.
Am new to jquery. Am I able to store item 1 in a variable and then test if john bassey was found?
can I do a redirect to another page within jquery?
As you find an answer of your original question, please award points and close your question.
If needed create a new thread with your new question
Thanks
If needed create a new thread with your new question
Thanks
ASKER
Thanks leakin971. My question has not been fully answered if you read the question very well.
ASKER
This is not even working
var r=confirm("Press a button and type your mesage here");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
var r=confirm("Press a button and type your mesage here");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works like a charm. Thanks a million.
You're welcome!
$('div.ContentLeft').has('
if this query has an object, then you found 'john bassey'
Check:
http://www.w3schools.com/jquery/sel_contains.asp
the confirm box code will look like:
var r=confirm("Press a button and type your mesage here");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}