#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Explain what is going on...


    I'm abit rusty when it comes to javascript and wonder what is going on here. Specifically I wonder what is happening with this thing:
    $('<a/>', {

    If I want to insert a different target, like "_top", how would I do that?

    Here is the code:
    $(function () {
    $.getJSON(urlJson, function(data){
    var li = $('<li/>');
    var icon;
    $.each(data, function(key, val) {
    li = $('<li/>');
    $('<a/>', {
    'href': "test.html?qwertyId=" + val.qwertyId,
    'data-transition': "slide",
    'rel': "external",
    'value': val.qwertyId,
    html: val.name + "</p>" + val.description
    }).appendTo(li);
    li.appendTo($('#qwerty-list'));
    });
    $('#qwerty-list').listview('refresh');
    });
    });
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    There jQuery is creating a new <a/> element that is inserted in the DOM by appending it to a certain <li/> element. This call:
    Code:
    $("<a/>", {href: "foo", target: "top"});
    would create an element whose HTML is <a href="foo" target="top"></a>

    http://learn.jquery.com/using-jquery...ting-elements/

IMN logo majestic logo threadwatch logo seochat tools logo