gtamil
gtamil

Reputation: 552

whole link created using attribute passing, not working.

Trying to create a link dynamically for some purpose

$('', {
   text: 'Click here!',
   href: 'http://www.example.com',
   title: 'Click to win'
   }).appendTo('body');

But this is not working ... anything wrong ?

http://jsfiddle.net/QJy6P/

Upvotes: 2

Views: 47

Answers (3)

Rafay
Rafay

Reputation: 31033

you have not selected the jquery option in the fiddle, also specify what are you creating <a/>

$(function(){
$('<a/>', {
   text: 'Click here!',
   href: 'http://www.example.com',
   title: 'Click to win'
   }).appendTo('body');
})

DEMO

Upvotes: 1

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76870

you should do:

$('<a/>', {
   text: 'Click here!',
   href: 'http://www.example.com',
   title: 'Click to win'
   }).appendTo('body');

Upvotes: 1

Jez
Jez

Reputation: 29983

You need the initial parameter to dynamically create your A link element:

$('<a/>', {
   text: 'Click here!',
   href: 'http://www.example.com',
   title: 'Click to win'
   }).appendTo('body');

Upvotes: 1

Related Questions