JQuery :: Replacing Href Attribute With Title Attr?
May 9, 2011
I'm trying to replace the value of href attribute of an element with the title attribute of that same element. The code pasted below works to some extent, but the last line doesn't.
jQuery(document).ready(function(jQuery){
jQuery(".ngg-gallery-thumbnail a").each(function (arr){
if (jQuery(this).attr("alt").substr(0,5)=="Video"){
jQuery(this).attr("rel","wp-prettyPhoto");
and I receive the click on the remove.gif. What I want to do is to get the title attribute of the div around and write it into the <p> tag instead of the name of the file now. I've achieved several selection (yeah i'm new to jquery) but can't figure this one out.
I am trying to get a href attr from variable msg. The problem is that the msg consists of not only <a element but it contains also <p element and because of that attr doesn't give any value.
var msg="<p><a href='/users/'>Username</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> var href=$(msg).attr('href');
how I can get the value of href from the above example?
I was following an example on youtube discussing the load() function which show you how to load content from a different page and this work great.
However in my quest to learn jquery I came across a different sample from wait-till-i.com which show you how to use a reusable code for multiple link with load($(this).attr('href') );
So my question is how can I add .secondList li:even' to select only what I need as in load($(this).attr('href'+ .secondList li:even')); assuming I have several page and all have a secondList of some sort.
<div> </div><div>This is hopefully simple. I have a bunch of links with titles, like TITLE="Facebook" and so on. I am adding JQuery to make the links open in a new window and
<span class="date" title="May 14, 2009">14 May 2009</span> and I'd like JQuery script to output it as this:<span class="date" title="">May 14, 2009</span> Basically, I'm checking the browser language and I want to display all dates in US date format to all users with EN-CA and EN-US browser language (and UK format to all other users). Please let me know if there is a better way of doing it, I couldn't find anything.
I am using the little tooltip script below. Normally, works fine, except when I clone an element which has a tooltip in it and append it to another element using something like: $("#table tbody").append($("#row").clone(true));.
Now, immediately after cloning it, I use jQuery to alert the title attribute, and it is in the new element. Then, when I view it using firefox, the title is gone, and obviously the tooltip cannot work.
/** Vertigo Tip by www.vertigo-project.com Requires jQuery */
I'm wanting to take all links pointing to external urls and insert a title tag with some text that I can then turn into a mouseover tooltip effect.The purpose is simple, we want to inform the visitor that by clicking on the link they would be taken away to another site. The warning message would be in the title tag.
Each external hyperlink already has an rel="external" tag so I can work off of that. This gives me:
As my element identifier. Now, in trying to insert this title tag, i've explored the append and appendTo but those refer to adding items to the end. I need the method that inserts this in between the <a></a> tags as it's own part of the hyperlink code. which method I should use to add something like this:
title="Clicking this link will take you away from this site"
I've even thought of possibly appending it as a hidden <span> item then revealing it on the mouseover.
One bit of additional info, i'm using Wordpress and want this to automatically deploy on all specified elements automatically.
I have a page that contains several HREFs. Each HREF that I'm interested in has a common parameter (parmX). Does anyone have a script example on how to find-and-replace parmX with parmY?
I'm assuming that I'd need to do this in the onload event - but I don't know much about Javascript.
I'm adding title attribute to some elements by using mouseenter function. But I would like to hide the shadow which comes by default nehind the tooltip frame and wrap the text in 2 lines!
I'm using jQuery Tooltip plugin (url) and need to access title attribute of element which plugin is applied to. As you know all title attributes are removed when tooltip function is applied, is there any way how to access them?
Basically, I have a php if statement which loads data into various classes when $id is equal to a number.
This is a video viewer, so there is one large video, and a series of small icons, which when pressed, need to load a new video into the large video through jquery.
As the id variable loads a lot of information into the large video classes, it kinda needs to be the php variable that needs to change rather than the class.
Is there some way of echoing a new attribute to replace the number in:
To the attribute taken from the small icon that was clicked.
I don't know why but it's not working no matter how much i try to do it. I was planning on posting some elements on a page's div and one of them allows for mutiple things going on at once, as in allows for someone to have more than one of something. And since i don't think that it'll be working right if i try to pull it from 1+ items with the same name it'd just show the last one? Or is it that PHP would show them as a list... either way it's seeming that .attr() doesn't allow for a name change for some odd reason. And i was wondering if there was any function to allow for this to be changed easily written within jquery.
I'm having an odd issue that i can't recreate in jsbin.i have an anchor tag:
<a class="navigateToCategory" href="#523">Instruments</a> and the code below: $('.navigateToCategory').bind('click',function(e){ e.preventDefault(); alert($(this).attr('href')); });
IE will give me [URL] while all other browsers give me "#523". I tried to recreate this using a small test case, but i can't do it. IE always returns the "#523" just like all the other browsers. here's a jsbin of it workinghttp://jsbin.com/unowe3/13 why .attr('href') would be different in IE vs Other browsers on my page but not jsbin? i'm using the same doctype and version of jquery, and identical code. i can't think of any code that i could have written that would affect how .attr('href') works. Edit: i did build a "hacky" solution for it by using $.browser.msie and an if statement, but it doesn't make any sense to me why it would be different in my situation vs any other.(not to mention, if it for some reason starts working properly, the "hacky" solution will cause it to not work)
I'm having an issue with doing a simple js task. I have a list of hyperlinks that contain various paths. For instance: a href="[URL] a href="[URL]
What I need is to remove the term "content" from all the hyperlinks in it's contain div. There is got to be a simple way of doing this and I can't seem to find the right direction. I also need to have the targets changed as well, which I was able to complete. window.onload = function(){
var anchors = document.getElementById('containerDiv').getElementsByTagName('a'); var links = "content"; for (var i=0; i<anchors.length; i++){ anchors[i].setAttribute('target', '_blank'); } }
I am trying to make a poll using jquery and php and am bit lost. I have a link <a href="poll.php?vote_id=1&post_id=25">I agree</a> Now how do I use jquery to select the vote_id and post_id. I need to store them in variables so that I can pass it on to a php file using get statement.
I'm pretty green to jQuery. I have a .load() calling in some content that has some links within it. After that content is loaded, am I able to change the attributes of those links? This is how I'm loading in the content:
I am having a problem changing HREF and Text of a link from javascript. My code is as colos <a href="javascript:Action(9,'remove');" id="thelink">Remove</a>
This isn't working. I'm using the code below to try to apply the href attribute of the first td in a row with class DataFormListTDDataGridItem and apply it to all td elements in that row (effectively want to make entire row clickable and direct it to the href specified by the href attribute in the first td of the row) -
Anyone know if there's a simple way of revealing all elements on a page that have a title attribute? I want to stick a script in a favelet to use as a development tool (highlight all titled elements with red border, etc)
I don't want it to be limited just to links or form elements.
If there's not something already out there, I'll probably have a hack at some existing favelets I have on my site, but no harm in asking if one's out there already, eh?