Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

3D

INTERN

ADOBE

ARDUINO

BITBUCKET

DOCKER

C4D

GIT

HTML

IPHONE

JAVASCRIPT

JTL-SHOP

LARAVEL

MAGENTO2

MYSQL

PHP

PLESK

PROCESSING

PYTHON

SUITECRM

SEO

TRYTON

THUNDERBIRD / ICEDOVE / FossaMail

TYPO3

TYPO3: BACKEND

TYPO3: TYPOSCRIPT

UNIX

VLC

VVVV

WINDOWS

WINDOWS 10

WORDPRESS

XAMPP

XT:C 4 (Veyton)

javascript-snippets

Javascript Snipptets and Helper

jQuery

add toggleText function

jQuery.fn.extend({
    toggleText: function (a, b) {
        if (this.html() == a) {
            this.html(b)
        }
        else {
            this.html(a)
        }
    }
});

http://jsfiddle.net/DmppM/

Vanilla JS

get Text from obj and setText to Obj

<div id="test"><img src="img1.gif"><br>My Text</div>
 
function getText( obj ) {
    return obj.textContent ? obj.textContent : obj.innerText;
}
 
function setText( obj, to ) {
    obj.textContent? obj.textContent = to : obj.innerText = to;
}
 
getText( document.getElementById('test') ) // 'My Text'
setText( document.getElementById('test').lastChild, 'bar' )

thanks 'meder':http://stackoverflow.com/questions/1646571/getting-the-value-of-text-from-a-text-object-in-javascript

javascript-snippets.txt · Zuletzt geändert: 2015/09/21 23:47 von admin