Is it possible to get a value from the external CSS of a page if the element that the style refers to has not been generated yet? (the element is to be generated dynamically).
The jQuery method I've seen is $('element').css('property','value');, but this relies on element being on the page. Is there a way of finding out what the property is set to within the CSS rather than the computed style of an element?
Will I have to do something ugly like add a hidden copy of the element to my page so that I can access its style attributes?
lets say i use jquery.get to retrive a website to string and how am i gonna select the whole table with class=product from it? $() seem cant work on string ....
i am using modalpopup to enter some value in a textfield. after the value is selected in the modalpopup view, the modalpopup is closed and the value has taken the propriate value. Even if the value is displyed in the textfield, the textfield1.text returns me string empty. when i see the source code (html), i see that even that the textfield is displaying something it hasn't really this value in it, because the appropriate html input field hasn't value yet.
thats the code i use to fill this textfield.
function CloseRequestModal(s)
{
document.getElementById('<%=txtRequest.ClientID%>').value = s;
var mpu = $find('<%=ModalPopupExtender3.ClientID%>');
mpu.hide();
}
Please Help,
Thanks in advance.
Hi, i've written this peace of code:
var a=function(){
};
a.name="test";
a.prop="test2";
Now if i debug the code with the console:
console.log(a.name);
console.log(a.prop);
In Firefox i get a.name="test" and a.prop="test2", while in Safari and Chrome i get a.prop="test2" but a.name="".
It seems that there's no way to assign a "name" property on a function in Webkit browsers. Do you know why? But the most important thing is, do you know a workaround for that?
I'm trying to use the form web part to do the following
[TextBox Field for typing a product number] [Submit Button]
On Click of submit should go to:
http://www.link.com/product.asp?=[TextBox Field Value]
I have a three strings of categories
"SharePoint,Azure,IT";
"BizTalk,Finance";
"SharePoint,Finance";
I need to find a way to check if a string contains for example "SharePoint" and "IT", or "BizTalk" and "Finance". The tests are individual strings themselces.
How would i loop through all the category strings (1 - 3) and only return the ones which have ALL instances of the souce.
i have tried the following
function doesExist(source, filterArray)
{
var substr = filterArray.split(" ");
jQuery.each(substr, function() {
var filterTest = this;
if(source.indexOf(filterTest) != -1 )
{
alert("true");
return true;
}else
{
alert("false");
return false;
}
});
}
with little success...the code above checks one at a time rather than both so the results returned are incorrect. Any help would be great.
Thanks
Chris
UPDATE: here is a link to a work in progress version..http://www.invisiblewebdesign.co.uk/temp/filter/#
Hi,
I have file upload UI element in which the user will upload images. Here I have to validate the height and width of the image in client side. Is it possible to find the size of the image having only the file path in JS?
Note: If No, is there any other way to find the dimensions in Client side?
Can I use intervals in a switch statement?
Like
switch (parseInt(troops[i])) {
case <10:
editbox.style.fontSize = "13px";
break;
case <100:
editbox.style.fontSize = "12px";
break;
case <1000:
editbox.style.fontSize = "8px";
editbox.size = 3;
//editbox.style.width = "18px";
break;
default:
editbox.style.fontSize = "10px";
}
???
Im having this weird reference issue when im trying to get a JSON file through query:
var themeData;
$.getJSON("json/sample.js", function(data) {
themeData = data.theme;
console.log(themeData.sample[0].description);
});
console.log(themeData.sample[0].description);
The first console.log works, the second doesnt. Im guessing because "data" already expired by the time the script gets there and themeData is just a mere pointer to "data". Is there a ways I can make sure themeData gets a duplicate of "data" and not just a pointer to it?
For the love of God I am not getting this easy code to work! It is always alerting out "null" which means that the string does not match the expression.
var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$";
function isEmailAddress(str) {
str = "[email protected]";
alert(str.match(pattern));
return str.match(pattern);
}
Flip is a great JQuery plugin for flipping blocks, but it doesn't preserve the background while it animates the flip.
For example, I have this pretty background, here, before I flip. While flipping, it gets ugly: here.
Is there a way I can flip this div nicely, keeping the pretty background I have, and maybe even achieve a smoother animation than I can get with Flip?
If I need to dive into this headfirst and code my own function for flipping a div, that's also doable, and I'd really appreciate some pointer there, if that's what I must do.
Thanks so much!
Is it considered a bad practice to pass around a large string or object (lets say from an ajax response) between functions? Would it be beneficial in any way save the response in a variable and keep reusing that variable?
So in the code it would be something like this:
var response;
$.post(url, function(resp){
response = resp;
})
function doSomething() {
// do something with the response here
}
vs
$.post(url, function(resp){
doSomething(resp);
})
function doSomething(resp) {
// do something with the resp here
}
Assume resp is a large object or string and it can be passed around between multiple functions.
Is there a way to check if there is a class named 'some-class-name' in css?
For example, I have:
<style type="text/css">
.box {
position: absolute;
left: 150%;
}
</style>
My intention is to randomly assign a class to a div on certain event:
var classList = []; //Need to populate this array
$('#updateClass').on('click', function() {
$('#resultDiv').attr('class',classList[Math.floor((Math.random()*classList.length)+1)]);
});
Is it possible to check by JS/jQuery whether a class named 'box' exists in the stylesheet?
Thanks.
How do I write a swtich for the following conditional?
If the url contains "foo", then settings.base_url is "bar".
The following is achieving the effect required but I've a feeling this would be more manageable in a switch:
var doc_location = document.location.href;
var url_strip = new RegExp("http:\/\/.*\/");
var base_url = url_strip.exec(doc_location)
var base_url_string = base_url[0];
//BASE URL CASES
// LOCAL
if (base_url_string.indexOf('xxx.local') > -1) {
settings = {
"base_url" : "http://xxx.local/"
};
}
// DEV
if (base_url_string.indexOf('xxx.dev.yyy.com') > -1) {
settings = {
"base_url" : "http://xxx.dev.yyy.com/xxx/"
};
}
Thanks
i have more than 1 divs
wid same ids but one has diplay='block'
and others have display='none'
i want to delete all the divs dat have display='none'
kindly tell the easiest way
I'm trying to integrate Mixpanel with GWT, but I have problems calling an event with a property and one value.
My function to track an simple event (without values):
public native void trackEvent(String eventName)/*-{
$wnd.mixpanel.track(eventName);
}-*/;
It works.
But when I want to add some properties and values, it doesn't work properly:
public native void trackComplexEvent(String eventName, String property,
String value)/*-{
$wnd.mixpanel.track(eventName, {property:value});
}-*/;
I have 2 problems with this:
1) Mixpanel says the property name is: "property"(yes, the name of the variable that I'm passing, not the value).
2) Mixpanel says the value is:undefined
An example from mixpanel web is:
mixpanel.track("Video Play", {"age": 13, "gender": "male"});
So, I guess the problem is I'm doing a wrong call or with wrong type of arguments.
Ok before i make spaghetti of this code i thought id ask around here. ive made a quiz for an online site.
The answers are stored in an array, and ive a function that checks the answers array to what youve clicked. then it counts them and gives you your score.
but i want to change the clor of the right answer wen the user clicks the score button. so the correct answers are highlighted. something like this https://www.shutterpoint.com/Home-Quiz.cfm (just hit submit at the bottom, no need to do the quiz).
the little answer icon at the side looks flashy but id rather just have the text change color. heres how my questions are formatted
<p>Depth of field is controlled by :?</p>
<p id = "question2"><input type="radio" name="question2" id="Answer1" value = "a" onClick ="recordAnswer(2,this.value)"/> The focal length of the lens. <br/>
<input type="radio" name="question2" id="Answer2" value = "b" onClick = "recordAnswer(2,this.value)"/> The size of the aperture opening. <br/>
<input type="radio" name="question2" id="Answer3" value = "c" onClick = "recordAnswer(2,this.value)"/> The distance between the camera and lens. <br/>
<input type="radio" name="question2" id="Answer4" value = "d" onClick = "recordAnswer(2,this.value)"/> All of these. <br/></p>
and these are the two functions that are called throughout. record answer is called every time the user clicks a button
function recordAnswer(question,answer)
{
answers[question-1] = answer;
}
this is the final button which calculates the score
function scoreQuiz()
{
var totalCorrect = 0;
for(var count = 0; count<correctAnswers.length;count++)
{
if(answers[count]== correctAnswers[count])
totalCorrect++;
}
<!--
alert("You scored " + totalCorrect + " out of 12 correct!");
-->
}
another function is best i think. ive already made attemots at it and know i have to set the color using
document.getElementById('question2').style.color = '#0000ff';
question2 being the p id
i think if i take in the value part of (input type....) ill be able to compare it to the answers array.
but im not quite sure how to do this. any helpers?
maybe something like this
document.getElementById("Answer1").style.color = '#0000ff';
using the id part of the (input type line)
i think i got it actually. ill post my answer in a sec
My jQuery code:
$(document).ready(function() {
chrome.extension.sendRequest({get: "height"}, function(response) {
height = response.value;
});
$("#id").css("height", height+"px");
});
You don't have to be concerned about the chrome.extension.sendRequest(), basically it communicates with a background page to fetch the value for "height" from localStorage and stores the value in global variable height.
The problem lies in $("#id") not being assigned the height value. However if I were to modify it such that it is now:
$(document).click(function() {
$("#id").css("height", height+"px");
});
it works. Any idea why?
Hi, I am using syntaxhighlighter (http://alexgorbatchev.com/wiki/SyntaxHighlighter) with a php source code with the ins and del tag.
What I would like to do is to have syntaxhighligher ignore those html tags so that they can be parsed correctly. So I'd like to to display:
test
instead of the default
< del test < /del
Anyone has any idea?
Forgive me as this is a time sensitive issue and I will have to switch the site back in a few hours so the link will be bad... but:
I am simply comparing two strings looking for a match with this function...
I have an array of objects called linkArray and I need to match the .src of each object to a .src I send it (the src of the clicked image). if the the src of the image I clicked matches the src of an object in my array, I set a variable to the link string of that object and return true, letting my page know that the link is available. Now, this works great in FF. But not in any other browser and I can't figure out for the life of me why. I have set up a dialogue box to literally compare, by eye, the two strings that should at the very least throw the message "match". Can anyone see what I am missing here???
here is the link... http://7thart.com/Jewish-History-and-Culture/Jews-and-Baseball-An-American-Love-Story
If you click any of the thumbnails on the left, you will activate the function. Again, I apologize as after a few hours I have to switch back to the original site and this link will be invalid. Thanks in advance for your help. (function below)...
function matchLink(a){
for(var i=0;i<linkArray.length;i++){
var fixLink = '../' + linkArray[i]['src'];
alert(fixLink + '\n = \n' + a);
if(fixLink == a){
alert('match');
newLink = linkArray[i]['link'];
return true;
}
}
return false;
}
Note: The "match" will return on two of the images.. the initial image, and the first thumbnail on the left. The second thumbnail SHOULD match, and the third one SHOULD NOT match.
Hi,
How can I get the complete html code of the element i'm mouseovering or clicking ?
Using document.onmouseover = function(e){ can I get the full underlying html code of the element which triggered the event ?
Right now, I am able to get the tag name or id or whatever.
What I would like is the whole code.
For example; if I'm mouseovering a table, I would like to get the string : <table><tr><td></td></tr></table>
Is this possible ?
I am looking at redesigning my website and was wondering if I could get some opinions.
I know that the rule is usually to design with users without JS first and foremost, but having looked at the stats, it appears 95% of the users online have JS enabled.
Would you recommend designing the website using JS and not bothering about people without it?
How to create regex pattern which is concatenate with variable, something like this:
var test ="52";
var re = new RegExp("/\b"+test+"\b/");
alert('51,52,53'.match(re));
Thanks