Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding an Hyperlink to a variable obtained by json
    primarykey
    data
    text
    <p>A newbie question, I obtain a var from a json through a cicle like this </p> <pre><code>$.each(json.Links,function(i,link) </code></pre> <p>I will then append that variable to content using this</p> <pre><code>$('#content').append('&lt;br&gt;').append(link); </code></pre> <p>This works, but I also would wish to add to the link an href so that when a user clicks on the link he will be direct to another page but I don't know how to do this</p> <p>Edit: Full html and script js</p> <pre><code> &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt; &lt;title&gt;Fake Delicious&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt; &lt;!-- Inserir banner --&gt; &lt;h1&gt;Delicious Testing Page&lt;/h1&gt; &lt;/header&gt; &lt;div id="content"&gt; coisa &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Script</p> <pre><code> var url="printTables.php?option=6"; $.getJSON(url,function(json) { $.each(json.Links,function(i,link) { var test="test"+i; var but=$("&lt;button&gt;Show info&lt;/button&gt;"); $(link).attr("href", link); $('#content').append('&lt;br&gt;').append(link).append($('&lt;div&gt;').append(but)); }); }) </code></pre> <p>The button at this stage isn't suposed to do anything. The link as I said it's correct since the html shows it properly I just now want to add an hyperlink to it for another page</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload