Traversing A Dom By Anything Other Than Tag Name Or ID
Mar 30, 2005
Is there any better way to traverse a DOM other than going by ID or tag name. I don't have IDs for certin things, but I do have a class associated with it, and traversing it by the tag is too encompassing.
Is there a good solution to this? I'm surprised there isn't mor functionality to traverse a DOM. IDs make the nodes very specific, and tags are too general, it seems like class is what you want to go by sometimes, but there is no function to do that. Can somebody let me know if I'm wrong on this matter?
View 8 Replies
ADVERTISEMENT
Aug 14, 2011
I have the following XML:
Code:
<root>
<MemberProvider name="myName">
<Marker>
<Latitude>-32.025469</Latitude>
<Longitude>115.950136</Longitude>
<Name>Beacon Lighting</Name>
<Address>219 21 William Street, Cannington WA 6107</Address>
<Phone>08 9356 6422</Phone>
<savingText>Members get 10 off RRP</savingText>
<disclaimer>Also save 10 off grid connected solar power systems</disclaimer>
</Marker> ......
Now in my Javascript, I have
Code:
var xmlrows = xmlDoc.documentElement.getElementsByTagName("Marker");
var xmlGroups = xmlDoc.documentElement.getElementsByTagName("MemberProvider");
//for the number of Member Providers listed
for (var i = 0; i < xmlrows.length; i++) {
var xmlrow = xmlrows[i];
var singleGroup = xmlGroups[i];
var xmlcellLongitude = xmlrow.getElementsByTagName("Longitude")[0];
var xmlcellLatitude = xmlrow.getElementsByTagName("Latitude")[0];
var point = new GLatLng(parseFloat(xmlcellLatitude.firstChild.data), parseFloat(xmlcellLongitude.firstChild.data));
//get the name
var name = singleGroup.getElementsByTagName("MemberProvider")[0].getAttribute("name");
Why do I have two variables loading the xml doc? The first appears to work, but the second (xmlGroups) does not. Every time I try and get the Name attribute from the MemberProvider node, it throws getElementsByTagName("MemberProvider")[0].getAttribute("name"); is null or not an object.
View 3 Replies
View Related
Apr 14, 2011
var divs = document.getElementsByTagName("div");
for (var i = 0, l = divs.length; i < l; i++) {
d1.write (divs[i].attributes.length+"-attribute length<BR>");
[code]...
I am hitting other objects, and I am not sure how to write the code to dive into those objects.
View 2 Replies
View Related
Jul 20, 2011
I have a table that has four columns in it. The second to last column has checkboxes in it. The last column has pulldowns in it with the class of "change_order". How can I make changes to the adjacent pulldown when the checkbox (in same row) is checked/unchecked? I am not able to select it.
function updateOrder(obj){
$j(obj).nextAll(".change_order").addClass("changedPD");
}
View 2 Replies
View Related
Nov 27, 2011
The code :
$('.TextHover').editable('/Task/SaveTags.php', {
type : 'text',
cancel : 'Cancel',
submit : 'Ok',
[Code]...
I put on alert to help me debug the returned value.What I need to show on alert is the 3, text of td with id='tId'.$(this).closest('tr').closest('td#tId').text() wouldn't work.$(this).closest('tr').next('td').html() returns null.
View 3 Replies
View Related
Aug 30, 2010
Does not work in IE6, but FF, SAF works only. any better way to solve this issue?[code]...
View 2 Replies
View Related
May 6, 2010
I have very simple question (ie probably simple for everyone with jQuery experience, but not for me). Lets say I have the following list
<div>
<li id="first"><a>one</a></li>
<li><a>two</a></li>
<li><a>three</a></li>
<li><a>four</a><li>
</div>
Now, if I want to get all the list items after the first, and change the text within the anchor tags, if a certain condition is met (eg change to capitals if it starts with a "t"). How can I do that? My approach was to get all the list items (after the first) with
[Code]...
View 1 Replies
View Related
Dec 8, 2010
JavaScript code is not traversing via Iframe with Cross Domain. Actually i was assigned with a project, to grab the top page URL, which has many Iframes, which are coming from different domains. The final sub domain has the JavaScript code, which has to grab the top page URL.
View 2 Replies
View Related
Oct 30, 2010
I want to start traversing backwards from the previous sibling of a specific div element. I've tried something like this but it does not seem to work because it's only selecting the specific div:
var start = $("#specific_div").prev("div"); // start from the previous div sibling of the "specific div"
jQuery.fn.reverse = Array.prototype.reverse;
start.reverse().each(function(i, E){
console.log(E.getAttributeNode("id").value);
});
[Code].....
View 2 Replies
View Related
Oct 28, 2011
<li><a class="selected" href="photo.jpg"><div class="details">blahblahblah</div></a></li>
I want to get the details div from the li that has an a tag with the class of selected. How do I write that correctly? I tried the following:
$("a.selected").parent().find(".details")
$("li["a[class=selected]"]").find(".details")
$("li[a[class=selected]]").find(".details")
$("li").filter("a.selected").find(".details")
I only want the results from the li that has an "a" tag with the class of "selected."
View 4 Replies
View Related
May 25, 2010
I have a form that submits to a third party WCF service. When the form submits it returns html. Based on that html I need my ajax submit to fire a success function according to the reply. The reply is as such:
<HTML><BODY>
<TABLE border='1'>
<TR><TD><b>Field Name</b></TD>
<TD><b>Field Value</b></TD>
</TR><TR>
<TD>SuccessFlag</TD>
<TD>TRUE</TD>
</TR><TR>
<TD>ResponseMessage</TD>
<TD>Service Cancelled</TD>
</TR></TABLE></BODY></HTML>
How would I write a success function if the SuccessFlag returns a TRUE in that td? I have tried
success:
function(data) {
var useTD = $(data).find('table').children('tbody tr td:nth(4)');
if (useTD == 1) {
$("#request").remove();
$("#requestSuccess").fadeIn("slow");
} else {
$("#request").remove();
$("#requestError").fadeIn("slow");
}
To no avail. I have also tried using the :contains but I can't get that right either.
View 2 Replies
View Related
May 13, 2011
I need to be able to call a certain td element in a table and I'm not able to edit the html (dynamically generated) so i was wondering if it is possible to target td elements like an array using jquery.
For instance, say I need to change the class of the 4th td element in the second tr element. how would I target that? is there a way to do it in array style like below?
<table class="myTable">
View 2 Replies
View Related
Mar 29, 2010
I'm getting this error when trying to simple traversing.
results.push.apply( results, checkSet ); jquery-1.4.2.js (line 2743)
I read that it might have something to do with arrays?
View 2 Replies
View Related