Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28-11-2008
Member
 
Join Date: Nov 2008
Posts: 1,185
Need help with JavaScript library "JQuery"

I seek your help with the JavaScript library "JQuery". My goal is to recover a portion of the contents of a variable that contains HTML.

For example:
HTML Code:
var data = "<html> <head .............</ html>";
My goal is to recover (to put in a variable) an element whose id = 'foo' for example.

If you have any ideas, please help!
Reply With Quote
  #2  
Old 28-11-2008
Member
 
Join Date: May 2008
Posts: 611
Re: Need help with JavaScript library "JQuery"

According to me, it is

$ ('foo')
Reply With Quote
  #3  
Old 28-11-2008
Member
 
Join Date: Nov 2008
Posts: 1,185
Re: Need help with JavaScript library "JQuery"

Sorry but no.

$ ('foo') with prototype or $ ( '# foo') with JQuery retrieves the element if the damage is loaded. Basically, HTML is in the current page.

My problem is different because the HTML code is in a variable.
Reply With Quote
  #4  
Old 28-11-2008
Member
 
Join Date: May 2008
Posts: 611
Re: Need help with JavaScript library "JQuery"

From this document: http://docs.jquery.com/Core


HTML Code:
$ (my_var ).$ ('# foo ')
Reply With Quote
  #5  
Old 28-11-2008
Member
 
Join Date: Nov 2008
Posts: 1,185
Re: Need help with JavaScript library "JQuery"

I did not succeeded with your method. However, reading the document more closely, I read: "Create DOM elements on-the-fly".

The solution to my problem is here: http://docs.jquery.com/Core/jQuery# htmlownerDocument

A small example of implementation

Code:
$ (). ready (function () { 
$ ( "# mylink"). click (function () { 
var mycodehtml = "<p> my para <span id='foo'> <strong> Myfoo </strong> </span> </p>"; 
var foo = $ ( "# foo", mycodehtml). html (); 
alert (foo); 
}); 
});
HTML Code:
<a id = "mylink"> click </a>
Always be persistent
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Need help with JavaScript library "JQuery""
Thread Thread Starter Forum Replies Last Post
Installing IE 8 get error:"Ordinal 423 could not be found in dynamic link library urlmon.dll" Rusheek Technology & Internet 3 05-02-2011 03:51 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" BansiJI Software Development 6 12-05-2010 10:02 AM
Error message "Old format or library type is invalid" when automating Excel PsYcHo 1 Windows Software 5 30-03-2010 05:21 AM
Keep getting error: "Microsoft visual basic c++ runtime library" Maff Vista Help 8 13-01-2008 02:18 AM


All times are GMT +5.5. The time now is 05:25 AM.