JQuery :: Selector To Match All Local Links?
Sep 4, 2009local links meaning links within the same document <a href="#somewhere"> types of links. how do i match all such links and events?
View 1 Replieslocal links meaning links within the same document <a href="#somewhere"> types of links. how do i match all such links and events?
View 1 RepliesI have a problems with selectors. I have the following HTML code:
<div
id
=
"myDatepicker1"
[Code]....
But the alert message does never appear and I did not get JavaScript errors. It seems that the selector does not match and so the alert message and the .hide() does not take effect.
How this can be done in jquery,
Let me explain the question using an example:
<html>
If you run it, the alert messageis "pic2", so jquery sees the entire document, but is there a way to easily restrict it to the sub-tree under the current node (in this case the sub-tree under the span node, since that's what was clicked)? Yes, I can do something like alert($("#div1 img:eq(1)").attr("alt")); //undefined as expected
But I am looking for a solution that's more dynamic, so I don't need to hard code #div1.
Here's my situation: I'd like to have links to my organization's sites open in the current window, but links to other sites open in a new window. The tricky part is that not all of our sites are on the same (or even similar) domains.This works just fine for matching foo.org:
$(".article a[href*='http:']").not("[href*=foo.org']").attr('target','_blank').addClass('external');
I'd like to widen this so that links to foo.org, bar.net and whatever,com all open in the current window. It seems like everything I try won't work because I can only match all instead of any.
The scenario: 1) Generate a popup window via script. 2) Populate it (again
via script) with content that features local (hash) links.
In IE 6.x this works - the links work as they should, moving the document to
that document position. However in FireFox 1.x the links load the main page
(the opener) in to the popup.
Both browsers populate the location.href of the popup with the main page's
href... but this only adversly affects FireFox (which seems to, in this
scenario, reload the whole page on a local link). I tried manually
populating the location.href but no joy.
I've appended an example which demonstrates the problem. I've tried to
shave it down as much as I could. Just save it to an HTML page and load it
up in FireFox. Click the button then scroll down and click the link...
instead of returning to the top of the page I get the opener page's HTML
populated into the popup.
Any thoughts on how to address this? I've Googled, but it may just be that
I've been unable to hit on the right terms to uncover the answer.
Code:
I tried to add links to open local xml files in browser in a dynamic table cells. I need help. I tried all ways but I think I miss something.I can open them without table just by document.write(xmlfile location).
function showResultsTable(searched, srchedname) {
// get the reference for the body
var mybody = document.getElementsByTagName("body")[0];
[code]....
Are there any difference between class selector and ID selector
View 2 Replies View RelatedI am new to jquery, and love it so far, but I am more of a designer, not a developer. I am learning jquery to enhance my sites, and I am having a problem figuring out buttons.
I have them working in firefox and safari, but in IE links do not work.
Here is the script I have, and the button code.
My menu navigation(Home, Hosting Solution, etc..)
1. The submenu links need to be centered in the middle of the div instead of aligned to the left.
2. Can the submenu links have a rounded box appear under them, instead of being underlined links. Like these at the top: [url]
3: The top tab needs to stay gray/active/on when the mouse is moved down to the submenu or when it is the active button.
Here is the link of the site [url]
I'm using jquery/ajax to create some links with window.open method. Here's the relevant code:
$("#content").empty();
$.ajax({
type: "GET",[code]..........
Basically, when you click a link a function is called with a parameter based on the particular link you run. Then the code runs through an xml file, and if the parent of the nodes I've cyling through has a value equal to the parameter past to the function, that node is used to create a new link with window.open function attached to it.It all works, or seems to, and when I alert what is being built, it looks right to me, yet the links don't work.I've attached a copy of one of the alerts of one of the links as it's built.
I'm trying to find an example of a country selector (which also provides a state selector if USA is chosen) then you cvan select the city, any samples out there?
View 2 Replies View RelatedI have an image wrapped inside a link tag.<a href="somepage.html"><img id="content" src="img/some.gif" /></a>
I want this .click target to be the link: $('a').click(function(e){
Instead, the target returned is the image [HTMLImageElement].
I have tried using closest()and currentTarget:
But they all still return the image, not the link.
I'm using the latest version of JQuery. How do write an expression to match multiple classes, but only for elements that are inputs of type="button" or type="submit"? I have figured out how to match multiple classes with the expression .
View 4 Replies View RelatedBit of a noob question, but I'm using the following code to get a menu tab to highlight/switch classautomatically based on the id of the page in the querystring. All is working well until the page ids hit double digits. Subsequently a menu with the link "p=10" and above will highlight when "p=1" in the location bar. How should Iamend the code to prevent this partial match? The menu item links always end after "p="; there are no furtherkeys in the querystring toact as a delimiter.
[Code]..
I am trying to get good using the $.each() in jQuery. I have a simple little task that I want to solve.
I have created a simple page with 100 boxes, each box with 4 colors. What I want to happen is if you click one box, it will change colors to the next box and so on. so for example here are 4 boxes
Red | Green | Blue | Yellow
If you click on Red you would get:
Green | Green | Blue | Yellow
If you click on the Green (1st one) you would get:
Blue | Green | Blue | Yellow
I have created a jsfiddle for you to view with what I have so far. I am stumpped at creating a match for the class name and if it matches to then go onto the next color in the array.
[URL]
Is there a possibility to get the alt text ...
var pattern='.foto-img img';
var text=$(this).find(pattern).attr('alt');
... by changing the pattern string only?I need to go this route:
var pattern='.foto-img img ???????';
var text=$(this).find(pattern).text();
I need to match an h3 with a p that has the same class. However, there are multiple elements and multiple classes, so I'm trying to store the class in a variable (x) and say "when I hover over the h3 with class x, get the p with class x and fade it in".
I can't seem to get it.
i currently have a problem which i cant resolve and i cant seem to find a solution (i actually not sure what to look for). My jquery level is medium-low and im trying to take it to a higher level right now.
I have a var which holds a href value. However i only need part of the string.
[Code]...
is there a concise way of matching a bunch of elements by style - specifically the display -
Code:
var hiddenParents = $(this).parents('has a style display: none');
I know about hidden & visbile etc - but need to match elements specifically hidden (ie NOT those that are children of hidden elements too)
I've been doing a lot of googling and im having touble finding information on how to do the following.I have an input field: $("#my_field")Which contains the following following text: |1||4||9||10|When the user clicks a button i want to check to if : |4| is in $("#my_field").val()I can find examples on how to check all input fields, however i only want to check the one.
View 3 Replies View RelatedCurrently I'm trying to create a menu with a mouseover effect on a link, which causes an image to display. All images are positioned on the same place, so the optical effect is that one image changes all the time. To achieve this I created an unordered list with the links / items in it, and I created a div with the (corresponding) images. On a mouseover event over a link, the index number of the current li element is stored in a variable, and I want to use that variable to select the corresponding image.
(So <li> index:2 corresponds to <img> index:2)
So in 'human language':
on mouseover of li {
var indexNumber = li.indexnumber
change class of img[indexNumber]
}
But I can't get it to work. I managed to store the 'current' indexnumber successfully in a variable:
var indexNumber = $("li").index(this);
But I can't use the variable to select the corresponding <img> I tried:
$('.slidemenuImgbox img:eq(indexNumber)').addClass('slidemenu_show');
But nothing happens
However when I do:
$('.slidemenuImgbox img:eq(1)').addClass('slidemenu_show');
The image with index:1 is changed.
How to use a variable in :eq()
To see a 'live' example (With no images changing): [URL]
I am trying to validate my 2 password fields with a custom message.Here's the code i'm trying to use, but it keeps failing:class="{required:true, equalTo:true, messages:{required:'Please type a password(min. 5 signs)', equalTo:'Pass dosen't match'}}"What is wrong, is it possible to do it by this code?
View 1 Replies View RelatedI'm using the Quicksearch plug-in and it does everything I need except for one thing. If I have two rows, for example:
"Blood oranges" and
"Green apples"
And I search for "a", it's going to match both rows because it matches the "a" in "oranges". What I need to is to match only the beginning of each word, so that typing "a" in this case would only give me "Green apples". Is this possible?
I have a 2 div JQuery slider and the height of one div id is relative and changes height values. Is there a way in jquery I can say "the height value of this div is equal to what the height value of the other div is?"
View 2 Replies View RelatedI have string and array:
text = "xxxxxxonexxxx"
array = ["one", "two"]
I need
if (text.match(array)) {...}
But it does not working. How can I check this?
I'm trying to create a branching form wherein the user selects a date using the datepicker plugin, then, depending on whether they choose a weekday or a Saturday, they are presented with one or the other of 2 select lists to choose the time.
I'm just getting started, and I can't seem to get the regex right. Here's a simplifed version of the relevant part of the datepicker,
$(function() {
$(".datepicker").datepicker({dateFormat: 'D, mm-dd-yy',buttonText: 'Click Me!', });
});
and here's the initial test to see if the chosen date falls on a weekday or a Saturday:
$(document).ready(function() {
$(':input[name=datepicker]').change(function() {
if ($(this).val()!=/^Sat,.*/)
{
[Code]....