Results 1 to 5 of 5

Thread: Need help with JavaScript library "JQuery"

  1. #1
    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!

  2. #2
    Join Date
    May 2008
    Posts
    611

    Re: Need help with JavaScript library "JQuery"

    According to me, it is

    $ ('foo')

  3. #3
    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.

  4. #4
    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 ')

  5. #5
    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

Similar Threads

  1. Replies: 3
    Last Post: 05-02-2011, 03:51 PM
  2. href="javascript:func()" vs href="#" onclick="javascript:func()"
    By BansiJI in forum Software Development
    Replies: 6
    Last Post: 12-05-2010, 10:02 AM
  3. Replies: 5
    Last Post: 30-03-2010, 05:21 AM
  4. Replies: 8
    Last Post: 13-01-2008, 02:18 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,919,744.61909 seconds with 17 queries