Javascript²Ù×÷SelectºÍOption
×¢Òâ:OptionÖеÄOÊÇÒª´óдµÄ£¬²»È»Óï·¨±¨´í
1.¶¯Ì¬´´½¨select
function createSelect(){
var mySelect = document.createElement("select");
mySelect.id = "mySelect";
document.body.appendChild(mySelect);
}
2.Ìí¼ÓÑ¡Ïîoption
function addOption(){
//¸ù¾Ýid²éÕÒ¶ÔÏó£¬
var obj=document.getElementById('mySelect');
//Ìí¼ÓÒ»¸öÑ¡Ïî
obj.add(new Option("Îı¾","Öµ")); //Õâ¸öÖ»ÄÜÔÚIEÖÐÓÐЧ
obj.options.add(new Option("text","value")); //Õâ¸ö¼æÈÝIEÓëfirefox
}
3.ɾ³ýËùÓÐÑ¡Ïîoption
function removeAll(){
var obj=document.getElementById('mySelect');
obj.options.length=0;
}
4.ɾ³ýÒ»¸öÑ¡Ïîoption
function removeOne(){
var obj=document.getElementById('mySelect');
//index,Ҫɾ³ýÑ¡ÏîµÄÐòºÅ£¬ÕâÀïÈ¡µ±Ç°Ñ¡ÖÐÑ¡ÏîµÄÐòºÅ
var index=obj.selectedIndex;
obj.options.remove(index);
}
5.»ñµÃÑ¡ÏîoptionµÄÖµ
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; //ÐòºÅ£¬È¡µ±Ç°Ñ¡ÖÐÑ¡ÏîµÄÐòºÅ
var val = obj.options[index].value;
6.»ñµÃÑ¡ÏîoptionµÄÎı¾
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; //ÐòºÅ£¬È¡µ±Ç°Ñ¡ÖÐÑ¡ÏîµÄÐòºÅ
var val = obj.options[index].text;
7.ÐÞ¸ÄÑ¡Ïîoption
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; //ÐòºÅ£¬È¡µ±Ç°Ñ¡ÖÐÑ¡ÏîµÄÐòºÅ
var val = obj.op
Ïà¹ØÎĵµ£º
<mce:script language=javascript><!--
var a=0;
// --></mce:script>
<?php
function func1()
{
$t="a=a+1;";
return $t."alert(a)";
}
?>
<?php
echo "<input type=button value='Sure' onclick=\"".func1()."\">";
?> ......
http://code.google.com/p/update-javascript-trim/
³£¼ûµÄд·¨Îª£º
function trim(s){
return s.replace(/^\s+|\s+$/g, '');
}
ÓÅ»¯ºótrimº¯ÊýµÄ´úÂëÈçÏ£º
function trim(str) {
str = str.replace(/^\s+/g, '');
for(var i = str.length - 1; i >= 0; i--){
if(!/^\s$/.test(str.substr(i,1) ......
1.Jscript ²»ÈÏΪÓï¾ä¿éÊÇÒ»¸öеķ¶Î§£¨×÷ÓÃÓò£©Ö»Óк¯Êý´´½¨Ðµķ¶Î§¡£
2.JScriptÓï¾äÖÐʹÓõȺţ¨=£©¸ø±äÁ¿¸³Öµ£ºµÈºÅÊǸ³ÖµÔËËã·û¡£
“=”ÔËËã·û×ó±ßµÄ²Ù×÷Ïî×ÜÊÇÒ»¸öLvalue£¬¼´¿ÉÒÔÊÇ£º
¶ÔÏó£¬
Êý×éÔªËØ£¬
¶ÔÏóÊôÐÔ¡£
“=”ÔËËã·ûÓұߵIJÙ×÷Ïî×ÜÊÇÒ»¸öRvalue ......
ÔÚasp.net¿ª·¢ÖУ¬¾³£»áÓõ½ºǫ́ºÍǰ̨µÄ½»»¥£¬¾Í´Ë×ܽáÁËÒ»µãc#ºÍjavascriptÏ໥²Ù×÷µÄ·½·¨
1.ÔÚºǫ́c#´úÂëÖе÷ÓÃjacascriptµÄ·½·¨
javascript´úÂ룺
<script type="text/javascript" language="javascript">
function test()
{
alert("oec2003");
return false;
}
</s ......
Á÷ÐÐµÄ JavaScript ¿â²»Ê¤Ã¶¾Ù£¬jQuery, MooTools, Prototype, Dojo, YUI¡£ÕâЩ JavaScript ¿â¹¦Äܷḻ£¬¼ÓÉÏËüÃǵIJå¼þ£¬¼¸ºõÄÜʤÈÎÈκι¤×÷£¬È»¶øÕâÊÇÓдú¼ÛµÄ£¬ÕâЩ¿âÍùÍùµ¼ÖÂÄãµÄÍøÒ³³ß´çÓ·Öס£ÔÚijЩ³¡ºÏ£¬Èç¹ûÄãÖ»ÏëÍê³ÉÌض¨µÄ¹¤×÷£¬¿ÉÒÔʹÓà һЩ¹¦ÄܸüרһµÄÇáÁ¿¿â£¬±¾ÎĽéÉÜÁË40¸ö·Ç³£³öÉ«µÄÇáÁ¿¼¶ JavaScript ¿â¡ ......