var myHeight = $(".sidebar").outerHeight(true); /* returns Height */
alert(myHeight); /* returns an integer e.g. 500 */
var addPixels = "px"; /* String variable with value "px" */
$(".text").css({"padding-bottom":myHeight}); /* myHeight = 500 NOT 500px */
i'm trying to concatenate to a string 2 variables that i'm adding together but i'm getting Nan as the result
what am i doing wrong? str_amount=parseInt(document.getElementById('amount').value); strfeeamount=parseInt(document.getElementById('feeamount').value); urltoajax=urltoajax + '&amount=' +str_amount +strfeeamount
I've tried various methods but haven't had any luck as of yet. I'm returning a series of 4 objects via AJAX calls. When each object loads, I'd like to iterate through it (no problem), and populate the "value" attribute of a hidden input field with each value from the object. I can't seem to find a way to intermingle jQuery and '+=', or find a jQuery substitute.
I've been learning javascript for about a week and I'm really struggling right now. This is a homework assignment to help in learning loops and arrays.
What I want to happen is when a form button is hit it will replace the array from the one previous instead of just adding to it. Hopefully that makes sense. What do I need to do? here's my code....
I have a table that I populate with an array using ASP. As each row is created, the form object names are appended a numeric, such as:
i = 1 <select name="select<%=i%>"> ... ... ... i = i+1 next
I then pass "i" to a javascript function, so that I can access the values of each form object. I can't figure out how to properly concatenate the "i" and still allow access to the value in the form object. Currently I have:
var ps = 'platSymbol' + I; alert(ps) var sel = 'document.frmUpdPlatGrp.' + ps + '.value' alert(sel)
I know I'm wrong, as this comes back as a complete string. Ultimately I want to have something like this:
var s = document.frmUpdPlatGrp.platSymbol2.value - so that I can actually get the value.
I have a validation script for upc codes which is currently working for values that are entered into one text box. I've been asked to break up the text box into 3 separate fields to accept the 1st digit, middle 10 digits, then last check digit. What I'm doing is substringing the initial values then concatenating them. What I'm not sure of is, how to handle the validation. I was previously firing an onBlur after the text box but now that I have three, and I need the values to concatenate into one for the validation. Should I just fire a function after the 3rd field that concatenates the 3 values, then pass that value to the validation function? Or is there a better way?
I was also wondering if there was something I could find like an input mask, but something that could just "overlay" on top of a regular text box with one value which could give the appearance of having separations for certain digits, in this case the first and last.
What I want to do specifically is add a CSS class to strings that start with an @ symbol. I can't seem to find any examples online and I haven't had enough experience with jquery to figure this out on my own.
I want it to highlight either the first word only, or just the line that the @ symbol is found on.
I have variables coming in from JSON files via AJAX calls. Each file will have 3 variables for different background colours. Depending on which button is clicked the background will change colour to the value specified in the JSON file.
Is there a simple way to just hide some text in a page? Browsing the documentation I found the .hide() function. But how can I tell jQuery to hide all occurrences of a specific string? If I use the :contains() Selector I can find the text but can only hide the element that contains the text not just the text.
I want to create a questions creation page. It has a Question Text Box and a Add Button.When users press the add button, there will be a newQuestion Text Box and a new Add Button appear in the next line. But the old Add Button will become a Delete Button and change its functionality.[code]I put all the Add Buttons and Minus Buttons into two different classes, ".buttonPlus" and ".buttonMinus".The .buttonPlus works well when the line is added by the main html. But it fails to work when it is added by the .append() function. It simply adds the .buttonPlus's CSS code to its button, but the$(".buttonPlus").click(function (event) {...} is NOT attached to the new buttonPlus.
The scenario would be something like checking if an element fulfills some complex conditions, something like if(myElement.is('div.someClass[someAttribute], td.someOtherClass[someAttribute]')) ... . Is there a way to parse that string only once, maybe create some sort of "compiled" version of the check, cache it, then give it to is ? Or does jQuery cache the string after parsing it once so I don't have to do anything?
I'm programming a function that breaks a massive string (2 million + characters) into "manageable" chunks of 500,000 characters. The function goes as follows [code]...
As you can see, everything should work fine, and the function should return a stringified json array (which would be parsed and sent to a server) but the loop stops after the first interval. When I decrease the length of "v" using substr to 5 characters, the loop works fine. What could the problem be?
To manipulate strings, but forexample when Iam programming an event with jquery and extract data from a textfield for example I can,t do this var msg=msg.subtring(0,5);
I've been using jquery for some time, and was very excited about the improvements in jquery 1.4 I have found however, that in one particular instance, jquery 1.4 seems to be performing slower than 1.3x, to the point that it has forced me to downgrade the script. I use jquery heavily throughout my web application; in this particular case, when a very large block of html consisting of a bunch of <tr>s is .appended (or .htmled, tried both) to a table, jquery 1.4 in firefox will give the "unresponsive script" error, prompting the user to stop, debug, or continue. The same block of html works perfectly fine in jquery 1.32 (and quite fast too). I haven't had time to do too much experimentation, as this is in a production environment, and thus downgrading was necessary as it was breaking the page, but I would love to figure out why this is happening so that I may optimize the code sometime in the near future. Have the improvements to .html resulted in code that causes higher cpu usage, or that would have a much higher overhead on longer strings? I've commented much of the code around the call, so that it pretty much consists of an ajax call that returns a chunk of html, which is inserted to a table (that I first empty). I thought it might be something with event bindings that occur after the insertion, but removal of these event bindings does not resolve the unresponsive script error. It seems the .html or .append is doing it. Note that this code, as is, works perfectly in jquery 1.3, even with event bindings, etc.
Does anyone have any ideas? My next step was going to be to try returning the entire table including the <table> tags, and doing a replace instead of an append, but if anyone has other suggestions to try, please let me know. Also, just as an aside, what do you guys consider the 'best practice' to be when returning dynamic data for a table (server side sorting, filtering etc from a db) ? Do you return just the data in json, and repeatedly clone a row element, replacing the values in each row (thus decreasing the size of the ajax call, but increasing the client side processing), or return the full html, and replace the innerHTML of the table?