JSFiddle - React, Tailwind, and code Playground

by dipish

HTML

<h1>Link middle-click example</h1>

<p>Try left-clicking and middle-clicking on the links</p>

<ul id="posts"></ul>

CSS

ul > li {
    margin-top: 1em;
}

JavaScript

var API_ENDPOINT = 'http://api.stackoverflow.com/1.1/search?tagged=javascript&pagesize=5&jsonp=?',
    $container = $('#posts');

$.getJSON(API_ENDPOINT).then(function(data) {
    var childElements = $.map(data.questions, function(item) {
        return $('<li>', {
            html: $('<a>', {
                 href: '//stackoverflow.com/questions/' + item.question_id,
                 text: item.title
            })
        });
    });
    $container.detach().html(childElements).appendTo('body');
});

$container.on('click', 'a', function(e) {
    e.preventDefault();
    alert('Maybe we will asynchonously load linked page here...')
});