javascript ×Ö·û´®´¦Àí
Ò»¡¢ÉùÃ÷×Ö·û´®:
var normal_monkey = "I am a monkey!<br>";
document.writeln("Normal monkey " + normal_monkey);
var bold_monkey = normal_monkey.bold();
document.writeln("Bold monkey " + bold_monkey);
ÕâÀïµÄÉùÃ÷£º var bold_monkey = normal_monkey.bold();
ºÍÏÂÃæ¶ÔÉùÃ÷ÊǵÈͬµÄ£º
var bold_monkey = "<b>" + normal_monkey + "</b>";
µÚ1¸ö°æ±¾µÄÉùÃ÷¿´ÆðÀ´Òª¼òÃ÷µÃ¶à¡£ÕâÀïÓõ½ÁË×Ö·û´®¶ÔÏóÖÐ
µÄbold¶ÔÏ󣬯äËûµÄ×Ö·û´®¶ÔÏó»¹ÓÐindexOf, charAt,
substring, ÒÔ¼°split, ÕâЩ·½·¨¿ÉÒÔÉîÈë×Ö·û´®µÄ×é³É½á¹¹¡£
Ê×ÏÈÎÒÃÇÑо¿Ò»ÏÂindexOf¡£
2¡¢indexOf
indexOfÓÃÓÚ·¢ÏÖһϵÁеÄ×Ö·ûÔÚÒ»¸ö×Ö·û´®ÖеÈλÖò¢¸æËßÄã×Ó×Ö·û´®µÄÆðʼλÖá£Èç
¹ûÒ»¸ö×Ö·û´®Öв¿°üº¬¸Ã×Ó×Ö·û´®ÔòindexOf·µ»Øreturns "-1."
Àý×Ó£º
var the_word = "monkey";
//ÈÃÎÒÃÇ´Óµ¥´Ê "monkey"¿ªÊ¼¡£
var location_of_m = the_word.indexOf("m");
//location_of_m(×ÖĸmµÄλÖÃ)½«Îª0£¬ÒòΪ×ÖĸmλÓÚ¸Ã×Ö·û´®µÄÆðʼλÖá£
var location_of_o = the_word.indexOf("o");
//location_of_o(×ÖĸoµÄλÖÃ)½«Îª1¡£
var location_of_key = the_word.indexOf("key");
//location_of_key(keyµÄλÖÃ)½«Îª3ÒòΪ×Ó×Ö·û´®“key”ÒÔ×Öĸk¿ªÊ¼£¬¶øk
ÔÚµ¥´ÊmonkeyÖеÄλÖÃÊÇ3¡£
var location_of_y = the_word.indexOf("y");
//location_of_y)×ÖĸyµÄλÖÃ)ÊÇ5¡£
var cheeky = the_word.indexOf("q");
//cheekyÖµÊÇ-1£¬ÒòΪÔÚµ¥´Ê“monkey”ÖÐûÓÐ×Öĸq¡£
indexOf¸üʵÓÃÖ®´¦:
var the_email = prompt("What’s your email address?", "");
var the_at_is_at = the_email.indexOf("@");
if (the_at_is_at&nbs
Ïà¹ØÎĵµ£º
1ÅжÏselectÑ¡ÏîÖÐ ÊÇ·ñ´æÔÚValue="paraValue"µÄItem
2ÏòselectÑ¡ÏîÖÐ ¼ÓÈëÒ»¸öItem
3´ÓselectÑ¡ÏîÖРɾ³ýÒ»¸öItem
4ɾ³ýselectÖÐÑ¡ÖеÄÏî
5ÐÞ¸ÄselectÑ¡ÏîÖÐ value="paraValue"µÄtextΪ"paraText"
6ÉèÖÃselectÖÐtext="paraText"µÄµ ......
keycode 0 =
keycode 1 =
keycode 2 =
keycode 3 =
keycode 4 =
keycode 5 =
keycode 6 =
keycode 7 =
keycode&nb ......
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"&nb ......