Page 1 of 1

Question for Jordan(jQuery)

Posted: Sat Jan 14, 2012 2:10 pm
by haakoo
He Jordan,

I'm trying to retrieve the href link from links(by class) and convert them to onclick
but I only get one(first one)

I know there's a part to use each in jquery,but can't make it work
Maybe,since you're not jquery illiterate :wink: ,can help me out.

I have 2 seperate links with normal href links,
Following is temp(onmouseover) code to see if the var shows-up and changes;

Code: Select all

function callUrl(){               
$('.style1').each(function (){
 var myUrl =$('a').attr('href'); 
                $("#Editbox1").val(myUrl)
});
}

Re: Question for Jordan(jQuery)

Posted: Sat Jan 14, 2012 3:09 pm
by jordan
hi haakoo,

not quite understand how you want to use it ?
but a way to retrieve and store all (array used) could be …

var myUrl=new Array();
$('.style1').each(function(index,val){myUrl[index]=val.href});


then you could use the array myUrl[?] for whatever ie. $('#Editbox1').val(myUrl[0])

Re: Question for Jordan(jQuery)

Posted: Sat Jan 14, 2012 9:33 pm
by haakoo
Hi Jordan,

Actualy i like to create an auto system to convert all href in textlinks by class into an onclick function
that way hrefs stay good for seo purposes and onclick for the action whatever;
like the dynamic iframe in your version 2 pack.
Since .js doesn't get indexed you could create another approach to the ajax!# hashbang by google.
I know you could apply events to text links(a very tedious approach)
But what if one uses the htmlbox-extension? no way to address anything at all
hint for an approach;
http://www.andrewpwatson.com/posts/crea ... ing-jquery
But first I need to get every used href in text

Hans

Re: Question for Jordan(jQuery)

Posted: Sat Jan 14, 2012 10:08 pm
by jordan
haakoo wrote:But first I need to get every used href in text
hello haakoo,

well the above example does do that, it stores all href of the class style1 of the page into the array myUrl
ie.
myUrl[0] = 'http://www.wysiwygwebbuilder.com/…'
myUrl[1] = 'http://www.google. …'
myUrl[2] = 'http://www.whatsever….'

however you want to use it from there … is ?

Re: Question for Jordan(jQuery)

Posted: Sat Jan 14, 2012 10:16 pm
by haakoo
Thanks,still need to tinker with it i guess :)

Hans