Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Bạn cũng có thể thấy điều này bằng cách sử dụng công cụ kiểm tra phần tử được cung cấp bởi Firebug. Gần phía trên bên trái của giao diện, có một nút trông giống như một con trỏ chuột lên một hình chữ nhật (xem Hình 2-3). Click vào nó để kích hoạt các thanh tra yếu tố. | CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS INSPECTING HTML USING THE ELEMENT INSPECTOR IN FIREBUG You can also see this by using the element inspection tool provided by Firebug. Near the top left of the console there s a button that looks like a mouse cursor over a rectangle see Figure 2-3 . Click it to activate the element inspector. Figure 2-3. The button to activate the element inspector After the inspector is active you can hover over different elements in the browser and they ll highlight with a blue outline. Hover over one of the paragraphs you just appended text to and click it. This brings up the HTML panel of Firebug with the current element collapsed and highlighted and a tab to expand the element see Figure 2-4 . 41 CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS Figure 2-4. The collapsed element as displayed after hovering over and clicking it Click the tab to expand the element and you can see the contents including the appended text which is contained within the paragraph element see Figure 2-5 . 42 CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS Figure 2-5. The expanded element including the dynamically added text You can use this technique throughout the rest of the exercises in this book to see where content and elements are being added to the DOM. Using .append and .prepend you can also add new elements to the DOM. For instance to add a new paragraph at the top of the browser page prepend a new element to the body using this code var para p text I m a new paragraph css background yellow body .prepend para Note This example uses a variable to store the new element before prepending it to the body. This is done to increase the legibility of the script. You ll be using this technique often throughout this book. .