Solved

Javascript question

Posted on 2013-10-24
1
207 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

707 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

15 Experts available now in Live!

Get 1:1 Help Now