|
|
i am sorry, i misunderstand.
This function is working.
Thank you have a nice day!!
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
Your welcome!
Help people,so poeple can help you.
|
|
|
|
|
JQuery[^] makes this very easy to do.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thank you, Mark;
Help people,so poeple can help you.
|
|
|
|
|
hi
L want click the button and save the div to the html file
thank you
|
|
|
|
|
Click what button? Save the div how; do you mean the source code or the screen display? Please try and reword your question to explain more clearly what problem you are trying to solve.
The best things in life are not things.
|
|
|
|
|
hi
I want click any button on the page then open the dialog to save the
content page to html format
thanks
|
|
|
|
|
I think you said that in your previous question. Which part are you having problems with?
The best things in life are not things.
|
|
|
|
|
I want when user click in my button just save the content page with any format could you help me?
Regards.
|
|
|
|
|
Some suggested possibilities here[^].
The best things in life are not things.
|
|
|
|
|
Legend create dynamic , I used jquery for create Legend GUI with click callback. each div have ID. expectation is while clicks div, the corresponding ID want to show. But here its showing only at last created div id only
<div id="legend"></div>
for (var i = 0; i < 3; i++) {
var id = "test" + i;
$("<div/>", {
"id": id,
"style": "width:30px; height:30px cursor:pointer; border:1px solid Green ;padding:1px; background-color:Green",
click: function() {
alert("ID = "+ id);
}
}).appendTo("#legend");
|
|
|
|
|
The problem is the function you created doesn't capture the value of the variable id, but the reference to that variable via a closure. To get a function that captures the current value of id create a function called createFunc(id) like this:
function createFunc(id)
{
var tmp = id;
return function() { alert("ID = " + tmp); };
}
then use it in your code like this:
...
click: createFunc(id);
...
Cheers!
—MRB
modified on Wednesday, July 6, 2011 12:15 PM
|
|
|
|
|
I have a code
if i click default3.aspx button(i am now default3.aspx).
After CallA function, com1's css was changed from null to css_1.
But after onload event com1's css is null.
why?
<ul>
<li id="com1">
<a href="default3.aspx"><img onclick="CallA()" />
</li>
</ul>
i double check com1's css was changed.
but after load_event com1's css was null.
function click_step2_menu() {
var li_imsi = document.getElementById("com1");
li_imsi.setAttribute("className", "selected");
}//function click_step2_menu()
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
If you want the LI with id 'com1' to use class 'css_1' by default after page load then you should change that HTML line to:
<li id="com1" class="css_1">
...
</li>
The default class for all tags is null or empty.
|
|
|
|
|
Hi All,
I am new to javascript and would like some help on a function to capture the ID of an element when the mouse is clicked. The element could be an image or what ever with an ID. I did some search online but I don't quite understand the code I saw so I'm going to attempt to write the code the way I think it should work. Basically I want to assign the ID of an element that has been selected using the mouse to a variable called Selected_Item. I would then swap out the value of Selected_item when a new item is selected. The following is what I have but I still don't know what I should put in the parenthesis so I placed a set of dashes in it for the time being. Please take a look at my code below, any help will be much appreciated, thanks in advance.
function CaptureID()
{ var Old_Item = '';
var Selected_Item = '';
if (Selected_Item = null)
{ Selected_Item = document.getElementById('-------');}
else
{
var Old_Item = Selected_Item;
var Selected_Item = document.getElementById('-------');
}
document.write("You have selected +'Selected_Item'");
}
|
|
|
|
|
Please format any code snippets you post using the "code block" toolbar item.
getElementById takes the ID of the element you are attempting to get (just like the name implies)
For instance
<div ID="myDiv"/>
getElementById("myDiv");
I suggest you look at JQuery also since it makes using JavaScript easier and cross browser.
JQuery[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi Mark, thanks for replying. I understand that getElementById gets the ID of an element. It looks to me like you had to manually put the ID myDiv in the parenthesis in your little example. Is there a way to automatically place the ID into the parenthesis when the mouse is clicked? Thanks again for replying.
|
|
|
|
|
It isn't really automatic but you can pass the id of the element to a function
<a id='someLink'></a>
<span id='someId' onclick="Foo('someLink')"/>
function Foo(id)
{
document.getElementById(id);
}
or
<a id='someLink' onclick="Foo(this.id)"></a>
however this wouldn't make much sense as you already have the object represented by the this parameter and would not need to use getElementById
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi
// +++++ get reference
function fuGetReference(X00)
// X00 string, value of ID or NAME
{
var X01=null;
if(X00!=null)
{if(X00.length>0)
{
if(fuIEexist())
{X01=window[X00];
if(X01==null){X01=document.getElementById(X00);}
if(X01==null){X01=document.getElementsByName(X00);}
}
else
{
X01=document[X00];
if(X01==null){X01=document.getElementById(X00);}
if(X01==null){X01=document.getElementsByName(X00);}
}
}
}
return X01;
}
Some browsers support value of ID like a pointer, wothout getElementByXXXX()
Cu.
|
|
|
|
|
Here is one way to do this:
<html>
<head>
<title>Test CaptureID</title>
<script type="text/javascript">
function CaptureID(sender) {
alert(sender.id);
}
function GetHandler_CaptureID(sender) {
return function() {
CaptureID(sender);
}
}
window.onload = function() {
var elementIDs = ["divHello", "divWorld"];
var element;
for (var i = 0; i < elementIDs.length; i++) {
element = document.getElementById(elementIDs[i]);
element.onclick = GetHandler_CaptureID(element);
}
};
</script>
</head>
<body>
<div>
<div id="divHello" style="background-color: Green;">Hello</div>
<div id="divWorld" style="background-color: Red;">World</div>
</div>
</body>
</html>
Instead of having the list of ID's in advance, you could also scan the DOM and look for elements with an ID or by some other criteria. jQuery would make this exceptionally easy, like Mark was saying.
Driven to the ARMs by x86.
|
|
|
|
|
I'm making an Android app with HTML and Javascript, and I need to get some JSON data from a server with Windows Authentication. jQuery seemed like the best approach for this, but I always get a 401 Unauthorized error. Does anyone know how to properly construct the right "GET" request(s) to make this happen?
|
|
|
|
|
We decided to just turn the app into a webpage and put it on the server with the data. In my opinion, this way is cleaner anyways.
If anyone has an answer for the original question, feel free to post anyways. I don't need it anymore for this project, but someone else might.
|
|
|
|
|
I try to execute this code(I place it between the head tags):
$(document).ready(function () {
alert("document ready occurred!");
});
$(window).load(function () {
alert("window load occurred!");
});
none of the functions is executed and I can't see any message box. What can be the reason and how can I fix it?
*I have references to the jquery libary in the page's master.
|
|
|
|
|
Have you placed in inside script tags?
<script>
$(document).ready(function () {
alert("document ready occurred!");
});
$(window).load(function () {
alert("window load occurred!");
});
</script>
I know the language. I've read a book. - _Madmatt
|
|
|
|