Solved

Change the li content with jquery

Posted on 2013-01-21
3
183 Views
Last Modified: 2013-01-21
Hi there,

I am trying to replace one of the list content with jquery, however it is not working and have error. Please advise what should be done. Appreciate your help.

I try to find the "contact us" list and replace it with "open ticket"

This is the menu:

<ul class="menu">
<li>
<a href="/sc/index.php/home">home</a>
</li>
<li>
<a href="/sc/index.php/announcements">announcements</a>
</li>
<li>
<a href="/sc/index.php/contact">contact us</a>
</li>
<li>
<a href="/sc/index.php/products">products</a>
</li>
</ul>

What I have tried but not successful.
$('ul.menu li:contains('contact us')').val('open ticket');

Thank you.
0
Comment
Question by:tomcattyy
  • 2
3 Comments
 
LVL 1

Author Comment

by:tomcattyy
ID: 38803070
I have also tried to  add alert box for

alert($('ul.menu li:eq(2)').val());

and it is blank, hope this helps for troubleshoot.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38803562
test page : http://jsfiddle.net/D2qnZ/
using :
$("ul.menu li:contains('contact us') a").text('open ticket');

Open in new window

0
 
LVL 1

Author Closing Comment

by:tomcattyy
ID: 38803724
Thanks for the quick response.
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question