Solved

Javascript question

Posted on 2013-10-24
1
219 Views
Last Modified: 2013-10-31
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');
});      
});
0
Comment
Question by:mdoland
1 Comment
 
LVL 7

Accepted Solution

by:
Ironhoofs earned 500 total points
ID: 39599815
This looks like jQuery to me. I think is a function that gets JSON data from a webserver url and renders it as a series of <li> tags. To add target="_top" to the <a> tag, try:

$('<a/>', {
'href': "test.html?qwertyId=" + val.qwertyId,
'data-transition': "slide",
'rel': "external",
'target': "_top",
'value': val.qwertyId, 
html: val.name + "</p>" + val.description
}).appendTo(li);

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now