JQuery :: Var X = $(this).textContent In Filter Function Does Not Work
Feb 13, 2011
I'm trying to assign the value of the textContent attribute from a DOM element to a var inside a filter function. Example code follows:
$('*').filter(function (i) {
var textValue = $(this).textContent;
if (textValue.substr(0,2) == "<$")
return true;
return false;
});
The assignment to textValue isn't working. The value of textValue is always null after the assignment. This happens with all element types. It even happens with a span element where by looking at the textContent attribute through a javascript debugger I can see the attribute has the expected string value; it is not null.
Why does the filter() portion of this code not trigger in jQuery 1.4.3+? Is there a better way to be doing this? The filter() does trigger and work properly in jQuery 1.4.2 and below.
I'm using the Google AJAX APIs, but some reason google.load works when run through normal javascript, but if I call the method from my jquery ready function it doesn't work. Code and output is below
window.loadFirebugConsole is not a function If I comment out line 3 in code.js, the console debug runs okay, so the ready function is running okay. Even though there's a reference to Firebug, the same error occurs in Safari too. Nothing on the page loads.
I'm sure that "insert.php" works because I've tried the <form method="POST" target="insert.php"> And it adds to the database through "insert.php". But when I remove the 'method="POST" target="insert.php"' And replace it with $.ajax() it won't work.
Here's the code: $(document).ready(function(){ $("#submit_wall").submit(function() { var message_wall = $('#message_wall').attr('value'); var message_wall = message_wall.replace(/</g, '<'); var message_wall = message_wall.replace(/>/g, '>'); var message_wall = message_wall.replace(/<.*?>/g, ''); var FeedUNum = $('#FeedUNum').attr('value'); var FeedConn = $('#FeedConn').attr('value'); $.ajax({ type: "POST", url: "insert.php", data: "FeedUnum="+FeedUNum+"&message_wall="+message_wall+"&FeedConn="+FeedConn, success: function(){ $("ul#wall").prepend('<li style="display: none;">'+message_wall+'</li>'); $("ul#wall li:first").fadeIn(); }}); return false; });});
The post is submitted and returns correctly (confirmed by firebug lite), however the code inside the nested function fails to execute on both IE6 and IE7. Works fine on IE8, everything else. $ ( "form.add" ). submit ( function () { //code outside of .post function executes successfully $ .post .....
I know it used to not, but according to the blur() docs page "the domain of the event has been extended to include all element types." Is this true, or do I need to set up an onClick event for the body and check to see if the currentTarget or its parents are the div I'm trying to fire the blur event on?
I'm new to jQuery, but learning fast, and loving the new functionality!I'm using a Flash upload component that all works fine, and once it's complete (file uploaded) it calls function.I'm running the Flash upload in a modal (nyroModal - very cool!). The link below does what I need it to do - navigate to a new page and re-size the modal:<a href="test2.aspx#blabla" class="nyroModal">Ajax Filtering Content #test</a>What I need to work out is how to make the JS function above work in the same way as this link. I know very little JS, but I think the 'class="nyroModal" needs to be part of the link in the function some how??
I want to change the color on every click of the div, by changing theclass and checking if hasClass. First removeClass, then addClass.But this won't work?Live demo:
http://www.edwinistrator.com/stuff/jquery/ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd">
my script that works in firefox/opera like a charm, but doesn't so in IE8.
Here we go:
$(document).ready(function(){ $(".folder").live('click',function(){ var id = $(this).attr("id"); if($('#' + id).hasClass('folderClosed')){
[Code].....
The basic idea is to show a "virtual" directorie from a mysql database over json. The first part works also quit well, only the .remove() function doesn't work right, which means the sub <ul> elements remaining on the page.
i tried a lot to load an external html into a div using .load() in chrome (it works in ff, ee, safary and opera). interesting point is online examples are working fine. but when i download the codes, chrome can not load external data on my machine!
here is my load function: $(function() { $.build = {}; $.extend($.build , {
That click listener doesn't get attached no matter what I do! I've confirmed that the other functions work, such as the toggle();, and it ALL works in firefox... what is going on?
I want to call a javascript function when a <span> is clicked, pass two variables to it, and then use jquery to hide that span.
A simple example is:
The variables (1,3) & (8,9) are loaded dynamically with a php script. Adding the two variables together isn't the intent of the script, but it seems the simplest way to explain what i'm after.
So how do you get $(this) to work in a function that has to have variables passed to it?
Iam using Raphael and add the same question in their google group too, but they said, its jquery specific. I think, jquery doesnt found my circle. Maybe different id - handling between SVG-specific and plain DOM elements?
I'm relatively new to JQuery and am having troubles trying to get two functions to work together. I have a pagination function and a modal dialog function. Each one is triggered by different anchor tags. My troubles happen whenever one function is triggered, the other function can not be triggered anymore. If I trigger the modal dialog, the pagination function can't be triggered, and when the pagination is triggered first, the modal dialog no longer triggers. I've tried to use .die() and .unbind() on the click events for the opposing function. That seems to work only once. then the opposing function can no longer be triggered. I think I am on the right path, just need to have some guidance on where I'm going wrong.
I have the following situation. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]"> <html xmlns="[URL]"> <head> <script type="text/javascript" src="jquery-latest.pack.js"></script> <script> $(document).ready(function() { //select all the a tag with name equal to modal $('a[name=modal]').click(function(e) { //Cancel the link behavior e.preventDefault(); ..... As you can see the script works when you click the Sticky Note button. How can I convert this script into ONLOAD working without clicking the button.
I am using the $(load) function to populate a div in my HTML with form. The code snippets look something like this. <html> ... ... <div id="formArea"></div> ... ... </html> $('#formArea').load('content/myForm.txt'); The form loads fine, but the input controls no longer work once the form is loaded using this AJAX technique.