Solved

Javascript question

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

830 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