HighDots Forums  

Display image if html content =

jQuery jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.


Discuss Display image if html content = in the jQuery forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wacko Jacko
 
Posts: n/a

Default Display image if html content = - 11-06-2009 , 09:24 PM






Hi People,

Is this possible with jQuery: If the content within a specific id
contains the word 'blah', display <img src="etc"/> inside this other
id. I want to display a specific avatar in a div only if the content
in another div contains that specific persons name.

Hope this makes sense!

Jack

Reply With Quote
  #2  
Old   
James
 
Posts: n/a

Default Re: Display image if html content = - 11-06-2009 , 09:32 PM






Here's one way to do it with jQuery using the contains() selector:
http://docs.jquery.com/Selectors/contains

if ( $("#box:contains('blah')").length ) {
$("#otherID").html('<img src="etc"/>');
}

Otherwise you could just get the text and use raw regular expressions,
or search()
http://www.w3schools.com/jsref/jsref_search.asp
or something.

On Nov 6, 4:24*pm, Wacko Jacko <jackson.be... (AT) gmail (DOT) com> wrote:
Quote:
Hi People,

Is this possible with jQuery: If the content within a specific id
contains the word 'blah', display <img src="etc"/> inside this other
id. I want to display a specific avatar in a div only if the content
in another div contains that specific persons name.

Hope this makes sense!

Jack

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.