The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Attribute Default Value
RainLover
post Jul 23 2014, 02:11 AM
Post #1


Advanced Member
****

Group: Members
Posts: 216
Joined: 16-November 09
Member No.: 10,346



Can you get an attribute default value so you don't have to repeat it in the following example:

CODE
<p title="foo" id="p">Hello, world!</p>
<input type="text" id="i">
<script>
    var p = document.getElementById('p'),
        i = document.getElementById('i');
    i.oninput = function () {
        p.title = this.value;
        if (this.value == 'bar') {
            p.title = 'foo';
        }
    };
</script>

DEMO

Is there something like p.title = p.title.defaultValue as we use for text fields?

This post has been edited by RainLover: Jul 23 2014, 02:11 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jul 23 2014, 02:48 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



You are talking about the tool tip that pops up when you hover over an element? As far as I know, there is no default value for the title attribute. The coder provides any title they want so I guess the defaultValue would be blank.
User is online!PM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 23 2014, 05:07 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,659
Joined: 10-August 06
Member No.: 7



Another idea is to store the default title value in a variable.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 04:57 PM