i have two back button generated but i need only one. i want to remove the button with rel='2'. below are the buttons
BACK
BACK
i am trying to remove it through jquery like
$('.prev-tab a[rel=2]').remove();
but i am not getting the result can any one correct my line of code. thanxs in advance for any kind of help
This should do it.
$('a.prev-tab[rel=2]').remove();
Based on your code:
$('.prev-tab a[rel=2]').remove(); // You are looking for an anchor tag with rel=2 who is a descendant of an element with class `prev-tab`
if you know that rel is going to be specific in your page on anchors .prev-tab then you can just use $('.prev-tab[rel=2]'). .prev-tab[rel=2] or just a[rel=2] is better than a.prev-tab[rel=2]
Try using below code.
$(".prev-tab").each(function(){
if($(this).attr(rel)==2)
{
$(this).remove();
}
});
This will also work (if no other anchor tag is not having 'rel' attribute you want to remove)..
$('a[rel=2]').remove();
Related
This should be easy but I can't find any topics about this, I think it's because I don't know how to phrase it correctly.
Problem:
When you hover over a link it gets cloned & appended to #container — however I want the link in #container to be the actual URL in its entirety, so if a link text says: "here is an article", I want the one that gets appended to #container to show: http:/www.myarticle.com/name-of-article.
I've tried to make my question very visually clear on CodePen, would someone check it out and advice me? :-)
http://codepen.io/StrengthandFreedom/pen/YqNrYO
The jQuery I use:
$('a').one('mouseover', function(){
$(this).clone().appendTo('#container');
});
Either JavaScript or jQuery solutions are fine, I use both.
You need to update the link text to the value of the href attribute.
$('a').one('mouseover', function(){
var href = $(this).attr('href');
$(this).clone().text(href).appendTo('#container');
});
http://codepen.io/anon/pen/eZgeNe
You may use this:
$('a').one('mouseover', function(){
$('#container').append($(this).attr('href'));
});
You need to catch the attribute of the link, which is done by using attr('attribute-handle')
I am using a .click function to switch out text based on menu clicks. (example:http://jsfiddle.net/3r9hcz3z/) It works great except that I am still pretty new to Jquery & I can't figure out how to add a link inside of on one of the .html() menu items.
Any help would be awesome. I know that there is a way to do it within the Jquery but just can't find the right coding. Thanks!
$('#menuone').click(function(){
$('#title').text("ONE");
$('#text').html("This is text & where I would like to be able to add a link");
});
$('#text').html("<a href='someUrl'>Link</a>");
This should do it.
one clean way to do this is to add a class to your anchor, and then set its href attribute through .attr:
$('.a_class').attr('href','http://example.com');
I have numerous URIs displayed in a scrollable html table. When I hover over the first file name the actual image will display as a tooltip (with the help of some jQuery code) next to the name because I have an anchor hard-coded to do just that. Unfortunately, I cannot figure out how create or modify anchors via javascript or jQuery on ther fly, so I need help.
Here is the one hard coded anchor that works just fine for a specific URI:
< a id="a$ci" class="screenshot" rel="http://www.xyz/ge/XpixColona003.png" title="XpixColona003.png">XpixColona003< /a>
I would be very happy id someone could show me how to modify the rel the title and text of the anchor with javascript or jQuery, or, show me how to create the correct anchor for every URI anew.
Thanks for your help in advance!
Alex
$("a").hover(function(){
var anc = $(this);
anc.attr("src","new value");
anc.attr("rel","new value");
anc.attr("title","new value");
});
I'm using an XML file that has a number for each section. The page loads a link for each section of the XML and puts the article number in the URL parameter (page.html?aid=###). When the link is clicked an overlay iframe pops up the with more information about that article. is calling the overlay iframe popup but I can't use more than one of the same ID for a page.
$(function(){
$('#b1').frameWarp();
});
Instead of using ID="b1", am I able to use each article number for the id? I cannot use class instead of ID.
Would there be another way to do this?
You could use $('a[id^="b"]'), but that's hugely inefficient and will probably match more than what you want it to. Alternatively, you could filter on a regex:
$('a').filter(function(){
var re = /^b[0-9]+$/;
return re.test($(this).attr('id'));
}).frameWarp();
It's not much more efficient, if at all, but at least it would rule out false positives.
Here is the answer courtesy of benalpert on reddit:
$('.b1').each(function() { $(this).frameWarp(); })
This allows the class to be used instead of ID without error.
Thanks to everyone for the help.
Does anyone know if you can remove head elements on a button click and how to do it with jQuery?
I am trying to get rid of certain script tags from the html head when a button is clicked.
For instance. I have 1 screen view with a slideshow controlled by an external javascript file. When I click on a button "Click to get rid of this elements JS" I want to remove the external javascript path from the HTML Head.
Any ideas. Have been at this thing for a week or so.
You can add an id to a script element then remove that ID:
<script type="text/javascript" src="init.js" id="initJs" ></script>
<span id="removeScript"></span>
$('#removeScript').click(function() {
$('#initJs').remove();
});
You can do this sort of thing using javascript, sure, but before you do it, you might want to ask yourself again why. Here's a link describing how to do it in pure javascript with a jquery example provided by the other answerer:
http://www.javascriptkit.com/javatutors/loadjavascriptcss2.shtml
But try to keep in mind that most modern browsers will keep these external resources in memory for at least as long as the page is open. Therefore, you won't really be doing much.
I don't think its a good Idea to remove Entire HEAD Element. 'Cause your Page may contain some more Elements (i.e., title, style..) which are appended to Head Element. If you want to remove a particular script Element do something like
$(function() {
$('input[type=button]').click(function() {
$('script[src=path/file.js]').remove();
});
});
Edit :
var flag = false;
function breakTheCode() {
if(!flag) {
//run your code
}else return;
}
$(function() {
$('input[type=button]').click(function() {
flag = true; //flag is set, so we no more using/ running your code
breakTheCode(); //call you function/method
});
});
For my part the best solution is to use ID on the scripts.
I read many page over the web, try many solutions, and the only one who works fine every time is to remove a script like a div with an id !
For remove js file : $("script[src='your.js']").remove();