Có 40+ tài liệu thuộc chủ đề "lập trình website"
tailieu.vn Xem trực tuyến Tải xuống
They only differ in the “script” they follow—the way they turn that original $time value into a point total.. At the bottom of scores.php , we’ll add the code to do this and output to JSON.. Fire up Firefox and type the URL to your scores.php file.. Because they run off a 10-minute cycle, the last digit of your system...
tailieu.vn Xem trực tuyến Tải xuống
It bears repeating because we’re still feeling the effects 10 years later.. <input type="submit". value="Post". onclick="postBreakfastLogEntry();">. First: note that we’re inside a pair of quotation marks. value="Post". With sufficiently com- plex code, we’d be forced to escape quotation marks. onclick="postBreakfastLogEntryWithStatus('draft');">. value="Save and Publish". onclick="postBreakfastLogEntryWithStatus('published');">. onclick="postBreakfastLogEntryWithStatus('discarded');">. value="Save and Publish". id="save_and_publish">. submitButton.onclick = postBreakfastLogEntry;. Here we’re doing what the previous example only...
tailieu.vn Xem trực tuyến Tải xuống
The second argument is our responder—the name of the function that will get called when the form’s submit event fires.. Of course it’s defined! It’s right there on the page! I’m staring straight at it!. Reload the page. Almost immediately the page load will halt, as Firebug points you to the offending line (see Figure 5-4).. From here, we can...
tailieu.vn Xem trực tuyến Tải xuống
we’ve already got a function handling that event.. event.preventDefault();. If the two fields we’re looking at are empty, we show a message and stop. Either way, we want to stop the default action of the form, so we move the event.preventDefault call to the top of the function (see Figure 5-8).. Imagine that each of the text boxes has a...
tailieu.vn Xem trực tuyến Tải xuống
custom events from anywhere in your code. you can also listen for custom events with the same API that you’d use to listen for native browser events.. Use dom:loaded when you want to work with the DOM in that narrow window of time before the page appears on the screen fully rendered. This is also a good time to talk...
tailieu.vn Xem trực tuyến Tải xuống
foo.hide();. foo.visible. false foo.show();. Element#visible simply reports on the element’s CSS display , returning true if it’s set to none . if (element.visible. element.hide();. else element.show();. true foo.toggle();. false foo.toggle();. <div class="news-item". id="item_1">. </div>. But what if we want to do more with CSS? It’s remarkably easy to style elements directly through JavaScript using the style property that exists on...
tailieu.vn Xem trực tuyến Tải xuống
when the structure or content of the inserted markup isn’t the same every time—because building long strings in JavaScript isn’t my idea of a fun afternoon. Think of it as a thin wrapper around innerHTML —just as assigning to the innerHTML property will erase whatever was there before, update will discard the original contents of the element, replacing it with...
tailieu.vn Xem trực tuyến Tải xuống
tr.appendChild(td1);. tr.appendChild(td2);. tr.appendChild(td3);. ...and append the row to the table body.. $('cities').down('tbody').insert(tr, 'bottom');. Three times as many lines! As is often the case, one approach is easy but sloppy, and the other is harder but more “correct.” Can’t we split the difference?. var tr = new Element('tr. tr.appendChild( new Element('td').update('Total'). tr.appendChild( new Element('td',. 'class': 'number'}).update(totalPopulation). tr.appendChild( new Element('td. Now append...
tailieu.vn Xem trực tuyến Tải xuống
Because scripts from different authors often coexist on the same page, it’s a bad idea to define too many functions in the global scope. Instead, what if you were to define one object in the global scope, and then attach all your functions to that object? You’d balk at defining a method named run , but BreakfastLog.run is much less...
tailieu.vn Xem trực tuyến Tải xuống
"Andrew Dupont throws for 23yds.". "Andrew Dupont throws for 39yds.". define properties for receivers this.receivingYards = 0;. this.receivingYards. this.catchPass(yards);. this.scorePoints(6);. Notice again that we’re not writing copy-and-paste code. this.isActive = true;. will be a starter for Sunday's game.");. this.isActive = false;. will spend Sunday on the bench.");. So now we’ve got two new methods on the Player class for managing...
tailieu.vn Xem trực tuyến Tải xuống
this.element = $(element);. this.totalElement = $(totalElement);. this.options = Object.extend({. selector: ".number". var numberElements = this.element.select(this.options.selector);. this.updateTotal();. this.totalElement.update(total);. We’re done writing the Totaler class, at least for now. Save it as totaler.js. We’ll be using the same data for this example, but we’ll need to change the table’s markup to fit with the changes we’ve made. <table id="cities">. <tr>. <th scope="col">Name</th>....
tailieu.vn Xem trực tuyến Tải xuống
arguments.length. If we take the parentheses off, though, we’re no longer calling the function—we’re just referring to it:. In the first example, result is set to 0 —the result of calling sum with no arguments. In the second example, result is set to the sum function itself. In effect, we’re giving sum an alias.. We’re going to look at a...
tailieu.vn Xem trực tuyến Tải xuống
Many of them are used within Prototype itself, but they’re likely to be useful in your own code as well.. "Never, never pour salt in your eyes.".gsub('never', 'always');. "Never, always pour salt in your eyes.". "Never, never pour salt in your eyes.".gsub(/never/i, 'always');. "always, always pour salt in your eyes.". But now we’ve got a new problem. The first. “never”...
tailieu.vn Xem trực tuyến Tải xuống
pour salt in your eyes.".escapeHTML();. pour salt in your eyes.". pour salt in your eyes.".unescapeHTML();. pour salt in your eyes.".stripTags();. "Never, never pour salt in your eyes.". "lorem-ipsum-dolor".underscore. "lorem_ipsum_dolor".dasherize. "lorem-ipsum-dolor".camelize. "never".capitalize. "NEVER".capitalize. "Never".capitalize. var warning = "Never, never pour salt in your eyes.". "Never, never...". ".blank. ".empty. "".empty. "".blank. var t = new Template("The quick brown #{first} jumps over the...
tailieu.vn Xem trực tuyến Tải xuống
just won the Heisman trophy.";. "Andrew Dupont just won the Heisman trophy.". "#{position} #{firstName} #{lastName} just won the Heisman trophy.");. Andrew Dupont just won the Heisman trophy.". firstName: this.firstName, lastName: this.lastName. "QB Andrew Dupont just won the Heisman trophy.". "The quick brown fox jumps over the lazy dog.". var warning = "Never, never pour salt in your eyes.". "Never, never...
tailieu.vn Xem trực tuyến Tải xuống
Object.toJSON(player);. Object.toJSON(qb);. Type Sniffing with Object.isX. The Object.isString, Object.isNumber, Object.isFunction Methods. Object.isString("foo". true Object.isNumber("foo". false Object.isFunction. Object.isNumber(4). true Object.isNumber(3 + 9). true Object.isNumber("3". The Object.isUndefined Method. Instead, we’ll use Object.isUndefined. alert(Object.isUndefined(third));. The Object.isArray, Object.isHash, Object.isElement Methods. 'object' Object.isArray(amigos). 'object' Object.isElement(villain). 'object' Object.isHash(partyFavors). if (Object.isString(element)). presidents.reverse();. presidents.reverse(true);. presidents.clear();. presidents.uniq();. presidents.without("Adams Monroe");
tailieu.vn Xem trực tuyến Tải xuống
Visualizing with Block-Level Elements. Visually, most elements are represented as blocks—big rectangles, if you prefer—and are thus called block-level elements.. As the primary pieces of page construction, block-level elements are broadly cus- tomizable. Block-level elements have implicit line breaks. But, as Figure 9-2 illustrates, any element can be made to behave like a block-level element, even if it isn’t one,...
tailieu.vn Xem trực tuyến Tải xuống
So we’ve got a box with 10 pixels of padding, 25 pixels of margin, and 5 pixels of border on all sides.. There are several ways to measure the box’s dimensions:. The most obvious way to the human eye is to measure from the outside edges of the border. A related approach would be to measure from the inside edges...
tailieu.vn Xem trực tuyến Tải xuống
We’ll call this the element’s positioning context. We can see for ourselves how changing the positioning mode of an element affects how that element’s children are rendered (see Figure 9-11):. A position value of relative , then, can be used to assign a new positioning context for all the element’s children while leaving it otherwise unchanged.. When we discuss an...
tailieu.vn Xem trực tuyến Tải xuống
oftentimes the version bundled with script.aculo.us is a little behind the stand-alone version. But the latest script.aculo.us and the latest Prototype, each fetched from its respective web site, are guaranteed to work together.. scriptaculous.js is the main file, the one that declares the script.aculo.us version number and ensures that Prototype is already loaded.. effects.js provides animations and advanced UI flourishes.....