Peterlu12 Peterlu12 - 1 year ago 75
Javascript Question

How to click each link individually in JS?

Try to separate both links individually by clicking each of them. What should I edit or add?

<script type="text/javascript">
$('#submit').click(function() {
if ($('#user').val() != '') {
alert('For demonstration purposes only. Please do not point your RSS reader to this server.');
var user = $('#user').val();

First One

.append('hhtp://' +
.attr('href', '' +

Second One

.append('' + user +
.attr('href', '' + user + '/rss');

Answer Source

    var user = $('#user').val();

      .append(jQuery('<a>').attr('href', 'hhtp://' +
            user).text('hhtp://' + user));
    .append(jQuery('<a>').attr('href', '' + user + '/rss').text('' + user + '/rss'));
<script src=""></script>
<input id="user" value="user"></input>    
<div id="output"></div>

Problem is in


when you add new link you erase all html content added before.

You should to remove this method in second link creation code.

And you should create a link element

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download