Hướng dẫn what is the difference between innerhtml and innertext with example? - sự khác biệt giữa innerhtml và innertext với ví dụ là gì?

Xem xét mã HTML sau đây.

This is my link collection:
  • Bye bye Borland
  • Welcome to Micro Focus

Bảng sau đây chi tiết các thuộc tính khác nhau trả về.

Mã số Giá trị trả lại
Browser.DOMEMENT ["// Div [@id = 'mylinks']"]. getProperty ["TextContents"]
This is my link collection:
Browser.DOMEMENT ["// Div [@id = 'mylinks']"].
This is my link collection:Bye bye Borland Welcome to Micro Focus
Browser.DOMEMENT ["// Div [@id = 'mylinks']"].
This is my link collection:
  • Bye bye Borland
  • Welcome to Micro Focus

Lưu ý: Trong thử nghiệm lụa 13,5 trở lên, khoảng trắng trong các văn bản, được lấy thông qua thuộc tính TextContents của một phần tử, được cắt tỉa liên tục trên tất cả các trình duyệt được hỗ trợ. Đối với một số phiên bản trình duyệt, xử lý khoảng trắng này khác với các phiên bản thử nghiệm lụa trước khi thử nghiệm lụa 13,5. Bạn có thể kích hoạt lại hành vi cũ bằng cách đặt tùy chọn OPT_CompiTion thành phiên bản thấp hơn 13.5.0. Ví dụ: để đặt tùy chọn thành Test Silk Test 13.0, hãy nhập phần sau vào tập lệnh của bạn: In Silk Test 13.5 or later, whitespace in texts, which are retrieved through the textContents property of an element, is trimmed consistently across all supported browsers. For some browser versions, this whitespace handling differs to Silk Test versions prior to Silk Test 13.5. You can re-enable the old behavior by setting the OPT_COMPATIBILITY option to a version lower than 13.5.0. For example, to set the option to Silk Test 13.0, type the following into your script:

'VB .NET code
Agent.SetOption["OPT_COMPATIBILITY", "13.0.0"]

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc and innerHTML are both properties of JavaScript. However, there are differences in which the text is handled. Let us check the syntax of the two and then take an example to look at the differences. 

    Syntax:  

    Bàn luận

    var x = document.getElementById['test'];
    • Bên trong và bên trong đều là các thuộc tính của JavaScript. Tuy nhiên, có sự khác biệt trong đó văn bản được xử lý. Hãy để chúng tôi kiểm tra cú pháp của cả hai và sau đó lấy một ví dụ để xem xét sự khác biệt. & NBSP;
    x.innerText
    • Chúng ta hãy giả sử rằng chúng ta có một biến JavaScript gọi là x.
    x.innerHTML

    Example:  

    Nội tâm

    Bài Viết Liên Quan

    Chủ Đề