Instead of multiple assignments, you can grab the property and use that
var text = ('innerText' in d)? 'innerText' : 'textContent';
d[text] = 'New text';
More Related Contents:
- 5 stars and the golden 5 stars are not together (When browsing with Internet explorer)
- Get the size of the screen, current web page and browser window
- contenteditable, set caret at the end of the text (cross-browser)
- Browser detection versus feature detection
- OnChange event handler for radio button (INPUT type=”radio”) doesn’t work as one value
- How is the default submit button on an HTML form determined?
- Show datalist labels but submit the actual value
- Jquery load() only working in firefox?
- Is there a way to make text unselectable on an HTML page? [duplicate]
- How to add/update an attribute to an HTML element using JavaScript?
- Prevent zoom cross-browser
- How to make Internet Explorer emulate pointer-events:none?
- textarea character limit
- Close Current Tab
- Enter key press behaves like a Tab in Javascript
- How do I change the ID of a HTML element with JavaScript?
- IE8 alternative to window.scrollY?
- Setting minimum size limit for a window minimization of browser?
- Is there any problem with using HTML5’s “data-*” attributes for older browsers?
- How to make an HTML element editable cross-browser?
- How to detect supported video formats for the HTML5 video tag?
- Testing for multiple screens with javascript
- Retrieving HTML attribute values “the DOM 0 way”
- Use JavaScript to intercept all document link clicks
- Best way to track onchange as-you-type in input type=”text”?
- Refresh Part of Page (div)
- How to reload current page without losing any form data?
- How to loop through selected elements with document.querySelectorAll
- Refresh Page and Keep Scroll Position
- How to get element in user-agent shadow root with JavaScript?