Hi All,
Is there a way in any browser to add/remove class names? For example, if I have a div with class names and I just want to remove/add 'name2' is there a way to do that?
Thanks,
rodchar
The following code works:
$(".valClear").each(function () {
if ($(this).val().indexOf(".png") == -1) {
$(this).val('');
}
});
However this doesn't (the value is removed even if it contains .png or .jpeg), what am I doing wrong?
$(".valClear").each(function () {
if (($(this).val().indexOf(".png") == -1) || ($(this).val().indexOf(".jpeg") == -1)) {
$(this).val('');
}
});
I'm having a Firefox-specific issue with a script I wrote to create 3d layouts.
The correct behavior is that the script pulls the background-color from an element and then uses that color to draw on the canvas. When a user mouses over a link and the background-color changes to the :hover rule, the color being drawn changes on the canvas changes as well. When the user mouses out, the color should revert back to non-hover color.
This works as expected in Webkit browsers and Opera, but Firefox chokes on it if mouseout is triggered and no mouseover event follows it. This is easier to see than for me to describe, and it's too much code to post here, so here is a link:
http://www.robnixondesigns.com/strangematter/
I understand why browsers would disallow websites from programically making the browser fullscreen. However, users typically expect the 'esc' button to exit from full screen, and browsers simply don't do that.
Is there any way to get the browser to exit from full screen.
Thanks.
Given an object like this:
var obj = {
first:{
second:{
third:'hi there'
}
}
};
And a key like this "first.second.third"
How can I get the value of the nested object "hi there"?
I think maybe the Array.reduce function could help, but not sure.
hi folks,
i got a webpage with some "cards" (divs) layin on it.
they are positioned in a star-like order, flowing to the background.
i want to bring cards from the background to the middle-foreground bei clicking on it (to focus the card "contact" for instance).
how can i realize this? is there any script which is already containing a function like this?
sometimes we loss the new keyword when define new object,
obj = new Clazz(); //correct
obj = Clazz(); //wrong, but no syntax error, hard to debug.
I want to write a function to help me create Class and make it new safe.
var Class = function(constructor){
//when constructor
// if not call by new
return new constructor();
// else
constructor();
}
var MyClazz = Class(function(name){
this.name = name
}, SuperClazz1, SuperClass2 )
MyClazz.extend({
show: function(){console.log(this.name)}
})
obj1 = new MyClazz();
obj2 = MyClazz();
// obj1 should same as obj2
Is it possible, any exists module?
I have a webpage with an input field where only digits are allowed.
The input field has an onkeyup event that starts this validating function:
function validate() {
var uah_amount = document.getElementById("UAH").value;
var allowed = /^\d+$/;
document.getElementById("error").innerHTML = document.getElementById("UAH").value;
if (!allowed.test(uah_amount)) {
document.getElementById("error").style.backgroundColor = "red";
}
}
Everything works as I expect until I hit Backspace button to remove some characters. In this case function always behaves as if I entered letters.
How to correct this?
I want to create a plugin called 'myPlugin'. Which method should I use and what is the difference between these two methods? Please tell me the advantages too. I am from designing background and not much programming knowledge.
var myPlugin = {
myId:"testId",
create:function(){},
destroy:function(){}
}
OR
function myPlugin() {
this.myId = "testId";
this.create = function(){};
this.destroy = function(){};
}
How to submit default data when using $.ajax?
I have tried:
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
// can't access anything here... (tried jqXHR.data but undefined)
});
$.ajaxSetup({
beforeSend: function(jqXHR, settings) {
// can't access anything here... (tried jqXHR.data but undefined)
}
});
I need this so I can send my CSRF token, each time and when logged in submit the user ID each time. I prefer not to submit a token in headers.
Thanks
I'm passing a method as a variable to be used as a callback. When its called, the "this" is not the object the method is a member of. How do I go about getting access to the method's object instance so I can get access to it variables and other member functions?
I have no control over the callback call method, its a separate library. All I do is call the binding from my object init method. I would have expected this inside my _connection method to have been its object.
jsPlumb.bind('connection', this._connection);
function SimpleSymbols(str) {
var letter =['a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var newstr = "";
for (var i = 0; i<str.length; i++){
if (str.charAt(i).toLowerCase() in letter){
newstr += "M";
}
else{
newstr += "X";
}
}
return newstr;
}
If str is "Argument goes here" it returns XXXXXXXXX. WHy doesn't it return MMMMMMMMMM?
hello,
/*Test scope problem*/
for(var i=1; i<3; i++){
//declare variables
var no = i;
//verify no
alert('setting '+no);
//timeout to recheck
setTimeout(function(){
alert('test '+no);
}, 500);
}
it alerts "setting 1" and "setting 2" as expected, but after the timeout it outputs "test 2" twice - for some reason the variable "no" is not reset after the first loop...
i've found only an "ugly" workaround...
/*Test scope problem*/
var func=function(no){
//verify no
alert('setting '+no);
//timeout to recheck
setTimeout(function(){
alert('test '+no);
}, 500);
}
for(var i=1; i<3; i++){
func(i);
}
Any ideas on how to workaround this problem in a more direct way? or is this the only way?
I can round to x amount of decimal places with math.round but is there a way to round left of the decimal? for example 5 becomes 05 if I specify 2 places
Have I any chance to serialize meta (any format, so I can store it in DB)?
var obj1 = {};
var obj2 = {};
obj1.link = obj2;
obj2.link = obj1;
var meta = [obj1, obj2];
As I understand the problem is that JSON serialize object`s links to objects.
hey all ,
background -
I'm using an activx that allow me to access some information on the client side,
By using the activex events and callback i'm updating server side from client.
i wrote a user control that register all activex's events so when one of the events occuer there is a callback to the server that handle this event.
I need to write some other user controls based on this control so on every callback this user controls will be render on the client side.
My question is -
what is the best way to make a shared infrastructure that handle this events and render the right content base on user controls?
is there any other ways i can use ?
thanks!
I'm trying to write a function that needs to know the property names of an object being passed in, like so:
var data = { "key1":"value1", "key2":"value2", etc}
^ i want the string value "key1"
How do I retrieve the string "key1" from data? I know I can set a property dynamically like data[prop]=value but i want to know what prop is from an object passed in.
If that doesn't make sense I suppose I could try to explain more. Thanks!
I eventually want to do something like:
for (var i = 0; i<data.length; i++)
{
var name = data[i].getPropertyName() <--- not a real function
// do stuff
}
Here's what I'm trying to do. I want to use Java Script to send an email. I have created a form with a subject text field, a message field, and a send button. I want for when the person clicks Send that it sends the email, but I want to avoid server side scripting.
Thanks
Hi,
I have a url like http://mywebsite.com/folder1/folder2/index
how to parse this above url and get all the values separately?
I want the output like
http,
mywebsite.com, folder1, folder2, index
Thanks in adavance
Is there any way to define a variable that can be used in multiple Web pages? For example, a string variable stores a certain value in page A and that value can be accessed in page B. I know cookies can do it. Is there any other way?