JavaScript - Remove Td With With Jquery?
Is there a way to do this? Maybe something like this...
Code: $("td:contains(' ')").css("display", "none"); Although for whatever reason, the code above isn't working... Similar TutorialsHi. I have a script which adds table rows dynamically to a table, when I delete a few removes with the jquery .remove(); sometimes the browser hangs and I have to refresh the page to make the page to work. Any ideas? I was thinking to put a sleep or timeout command just after the row removal, because if I remove rows slowly it won't crash, but if you remove 3-4 rows quickly it will crash, please help! Hi. I want to make jQuery check, whether if I've supplied text into all fields. If not, then jQuery adds some styling to the input boxes pointing out, the user must type something. However, I do not want to do many, many lines of jQuery to do this with all of the inputs. Is there a way to check which input is empty, and then add styling to the individual one? And then remove the style, if it's no longer empty. Like - ONE piece of code, that checks all of the inputs, and adds style to the ones, that are empty. Here's what I have right now. Code: <script type="text/javascript"> $(function(){ $('#register').click(function(){ var username = $('#username').val(); var password = $('#password').val(); if(username == ""){ $('#username').css({ background: '#F3CACA', border: '1px solid #E61A1A' }); }else{ $('#username').removeAttr('style'); } return false; }); }); </script> I played around with if(username == "" || password == ""). It works, but then I got lost on how to add styles to the individual input that is empty. Hello, I'm trying to remove one of the $ signs from this string below. I've gotten as far as removing them both. I'm having trouble removing one of them. Can someone help? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script> $(document).ready(function(){ /*v = $("span.name").html().replace(/,/g,''); $("span.name").html(v);*/ v = $("div.test td").html().replace(/\$/g,''); $("div.test td").html(v); }); </script> <!-- <span class="name"><span class="gost">Yahoo</span>, </span>--> <div class="test"> <table><tr> <td>3-7 Business Days $$0</td></tr></table> </div> </body> </html> Hi All, Why is the Option constructor converting my text as follows? text = ' 1:30 pm' Option tag that gets generated: <option value="10">&nbsp;&nbsp;1:30 pm</option> How do I suppress the conversion of the & to & by the constructor? I've tried escaping the & but that's a no go. Thanks in advance for any help on this. JD So, i have this code which retrieves php files for me using jquery and id love to get it working with Jquery history plugin. I tried modifying the code i got from the ajax demo to work for me, but i just couldnt do it as i do not know any javascript really.. ( actually what i tried was simply to change "#ajax-links a" to "#menu li a" and .html to .php ..but nothing.. :rolleyes: Id be very gratefull if someone would help me out with this one. All related code can be found bellow (the ones that should be needed anyways): This is the code that retrieves php files inside "#content" when item from "#menu li a" with the specified id is clicked Code: $(document).ready(function(){ //References var change = $("#menu li a"); var loading = $("#loading"); var content = $("#content"); //Manage click events change.click(function(){ //show the loading bar showLoading(); //load selected section if(this.id == "home") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/index.php", hideLoading); content.slideDown(); } else if(this.id == "secondpage") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/secondpage.php", hideLoading); content.slideDown(); } else { //hide loading bar if there is no selected section hideLoading(); } }); //show loading bar function showLoading(){ loading .css({visibility:"visible"}) .css({opacity:"1"}) .css({display:"block"}) ; } //hide loading bar function hideLoading(){ loading.fadeTo(1000, 0); }; }); Heres the structure of the menu/content Code: <ul id="menu"> <li><a id="home" class="normal" href="#Home"></a></li> <li><a id="secondpage" class="normal" href="#Secondpage"></a></li> </ul> <div id="content"> <ul id="sec-menu"> <li><a id="link1" class="normal" href="#">Link1</a></li> <li><a id="link2" class="normal" href="#">Link2</a></li> </ul> </div> Heres the code that jquery history plugin uses in demo for ajax Code: jQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); hi, i have a jquery problem... this script is not working with jquery-1.4.2.min, but it works with jquery-1.2.6.min.js, can anyone help me???the script is the above: (it is not working the tab actions, the slideout works...) http://www.benjaminsterling.com/wp-c...es/sidetab.htm the javascript code is the above: PHP Code: var jqsideTabs; var tabs, h = 50, r = 0,ra = 0; $(document) .ready(function(){ jqsideTabs = $('#sideTabs').addClass('closed'); tabs = jqsideTabs .find('.tab h3') .clone() .appendTo(jqsideTabs) .each(function(i){ var that = $(this), cls = '',ow,newThis, newEl; if( i == 0 ) cls = ' active'; newEl = $('<a href="#" class="tabLinks'+cls+'">' + that.text() + '</a>'); that.replaceWith(newEl); ow = newEl.outerWidth(); if( i == 0 ) ra = ow; else r = ow; h = newEl.css({'top':h , 'right': -ow }).height() + h; newThis = newEl.get(0); newThis.jq = newEl; newThis.i = i; newEl.click(function(){ var el = this.jq; if( jqsideTabs.hasClass( 'closed' ) ){ jqsideTabs.removeClass('closed'); } else if( !jqsideTabs.hasClass( 'closed' ) && el.hasClass('active') ){ jqsideTabs.addClass('closed'); } el .siblings() .removeClass('active') .css({'right': -r }) .end() .addClass('active') .css({'right': -ra }); tabs.eq( this.i ).show().siblings('.tab').hide(); return false; }); }) .end() .parent() .eq(0) .addClass('active') .end() .filter(':not(:eq(0))') .hide() .end(); jqsideTabs.bind("mouseleave",function(){ jqsideTabs .animate({left:-310}, 'fast', function(){ jqsideTabs.addClass('closed').removeAttr('style'); }); }); }); and the html file is: [HTML] <div id="sideTabs"> <div class="tab"> <h3>Tab 1</h3> <div class="gut"> <p>Some text</p> </div> </div> <div class="tab"> <h3>Tab 2</h3> <div class="gut"> <ul> <li>link</li> </ul> </div> </div> <div class="tab"> <h3>Tab 3</h3> <div class="gut"> <ul> <li>link</li> </ul> </div> </div> </div> [/HTML] the problem is that the tab button works, but the content doesnt change...in all of tabs showing the same text(showing all tbas content).... can anyone help...please..... i keep getting the error GET http://code.jquery.com/jquery.min.map net::ERR_TOO_MANY_REDIRECTS & Failed to load resource: net::ERR_TOO_MANY_REDIRECTS when i load my page...and the havascript doesn't work properly on ym page...how do i resolve this. thanx in advance var s="attr" var i=$(s) // jQuery(elem).attr(attr,eval("elm"+attr)); jQuery(elem).$(s)(attr,eval("elm"+attr));//i tried this. how to assign a variable name in the above code(in place of s) so that i need to add an attribute to the element "elem". Ok, I would post my entire data here but then yall would be reading insane amounts of script. I've got a div content jquery slider on my site I am making and it works beautifully in all browsers(took me a while). Then, I decided why not have it where when people click on a "read more" link that it pops up a box, instead of directing to the new page, and displays the contents of a div. It would not work at all. My question is there a possible way to do this?
Hello, I'm currently using this code: I want it so that there isnt a box around the countdown, and the countdown is the same text as "you will be redirected in" here is it in action: http://www.playelite.org/redirect.html Code: <form name="redirect"> <center> <font face="Arial"><b>You will be redirected in: <form> <input type="text" size="3" border="0" name="redirect2"> </form> seconds</b></font> </center> <script> <!-- var targetURL="http://google.com" var countdownfrom=10 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } setTimeout("countredirect()",1000) } countredirect() //--> </script> Thanks I'm using jQuerys' $.ajax to load a div with some details in it and i want to use the esc key to close the div. Heres the code so far Code: $('.username span').click(function(){ $('.MiniPro').remove(); ID = $(this).parent().attr('ID'); This = $(this).parent(); miniPro(); }); function miniPro() { $(This).append('<div class="MiniPro">Loading...</div>'); $.ajax({ type: 'POST', data: 'userID='+ID, url: 'processing/miniPro.php', success: function(msg) { $('.MiniPro').remove(); $(This).append('<div class="MiniPro"'+msg+'<div class="MiniProClose">X</div></div>'); } }); } Is it even possible to do that? Hi all, here i got a problem, i want to remove all the Li tag that with a classname"test" . Code: <html> <head> <title>Introduction to the DOM</title> <script> window.onload = function(){ var li = document.getElementsByTagName("li"); for ( var j = 0; j < li.length; j++ ) { if(li[j].getAttribute('class')=='test'){ li[j].parentNode.removeChild( li[j] ); } } }; </script> </head> <body> <h1>Introduction to the DOM</h1> <p class="test">There are a number of reasons why the DOM is awesome, here are some:</p> <ul> <li class="ppp">ppp.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> </ul> </body> </html> i am doing an edit operation in my web page by changing a image, but when i am revisiting the page it is showing older image rather than new one. So can any one say how to refresh the page without using any button like window.location.reload(). Is there any way to use math.random in url?? I am using this script that gets messed up when you resize the window. I figured out that I could use this other script to do stuff just after the window gets resized. Code: (function($,sr){ // debouncing function from John Hann // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ var debounce = function (func, threshold, execAsap) { var timeout; return function debounced () { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; }; if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; } // smartresize jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery,'smartresize'); // usage: $(window).smartresize(function(){ // code that takes it easy... }); So I re-instantiate the misbehaving script in there so it fires whenever the window is resized (I changed it to 500 so it really only fires once after you are done resizing). This fixes it. The new instance doesn't have a problem but the old instance is still there and messed up. so I use. $($.misbehaving-script).remove(); just before instantiating after window resize, which gets rid of broken instance. Problem solved.. Except that messes up a different script! It's driving me crazy. Any advice would of course be very welcome. Hi Guys, I'm new at JS. I need to remove TR elements from parent table but the problem is there are no table ID/Name Is it possible to perform it? Please see attach - i need remove red marked block... what scrip i have to use if i will put it to the green block? Thank you. Hi I have javascript which calls a load of Java applet functions, there are many of these, and the parameters are all the same. The only thing that changes is the name of the function to call. So here is an example of the Javascript: Code: function answercall() { try { document.frm.response.value = document.Telepop.Answercall(document.telepopfrm.extension.value); } catch(err) { alert(err.description); } } function clearcall() { try { document.telepopfrm.response.value = document.Telepop.Clearcall(document.telepopfrm.extension.value); } catch(err) { alert(err.description); } } function holdcall() { try { document.telepopfrm.response.value = document.Telepop.Holdcall(document.telepopfrm.extension.value); } catch(err) { alert(err.description); } } etc, etc.... and the html like this: <input type="button" value="Answer" onclick="answercall()" /> <input type="button" value="Hangup" onclick="clearcall()" /> <input type="button" value="Hold" onclick="holdcall()" /> There does seem to be a lot of duplication here, so I was wondering of ways to reduce or eliminate the duplication. any ideas? AC So say if my string was.. Code: a = "Hello"; alert(a); How do I get it to say; Code: alert("ello"); So how do I take off the 'H' in this example.. I'm trying to delete a item in a list. I'm getting a method not allowed error in IE8. Code: var selectOptions = document.getElementById('id_employees_cbo'); for (var i=0; i<selectOptions.options.length; i++) { if (selectOptions.options[i].selected == true) { selectOptions.options[i].remove(); break; } } Is there another way to do this? Thanks I'm working on a webpage where I used this code to display random images. I used it for three images in a row and I keep getting white spacing in between them when they should be right up against each other. This is the code I'm using: Code: <script language="JavaScript"> <!-- /* Random Image Script- By JavaScript Kit (http://www.javascriptkit.com) Over 400+ free JavaScripts here! Keep this notice intact please */ function random_imglink(){ var myimagesblue=new Array() //specify random images below. You can have as many as you wish myimagesblue[1]="images/circles_blue/circle_bl_01.jpg" myimagesblue[2]="images/circles_blue/circle_bl_02.jpg" myimagesblue[3]="images/circles_blue/circle_bl_03.jpg" myimagesblue[4]="images/circles_blue/circle_bl_04.jpg" myimagesblue[5]="images/circles_blue/circle_bl_05.jpg" myimagesblue[6]="images/circles_blue/circle_bl_06.jpg" myimagesblue[7]="images/circles_blue/circle_bl_07.jpg" myimagesblue[8]="images/circles_blue/circle_bl_08.jpg" myimagesblue[9]="images/circles_blue/circle_bl_09.jpg" myimagesblue[10]="images/circles_blue/circle_bl_10.jpg" myimagesblue[11]="images/circles_blue/circle_bl_11.jpg" var ry=Math.floor(Math.random()*myimagesblue.length) if (ry==0) ry=1 document.write('<img src="'+myimagesblue[ry]+'" border=0>') } random_imglink() //--> </script> Is there a way to get the white space removed? Thanks |