/    Sign up×
Community /Pin to ProfileBookmark

Hover and Click help

Hi all,

I’m quite new to javascript, having some difficultly accomplishing a goal. I want to have a block of text wtih overflow:hidden, and when you mouse over this box an image pops up prompting you to click on it, when you click on it– the overflow is set to automatic.

I believe I need to use two functions, one for the hover, one for the click.

so far I have the following for the javascript, something tells me it is horrendously incorrect.

function mouseover(id) {
document.b1.src=”./dropdown.jpg”;
}

function onclick(id) {
document.b1.display = “scroll:auto”

Anyone know a good way to do this?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorAug 01.2008 — The simple way is to use HTML [B]title[/B] attribute to invite user for a click:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="text/javascript"&gt;
&lt;style type="text/css"&gt;
table{
width:100px;
border:solid 1px #000 collapse;
}
table td{
width:100px;
height:100px;
}
table td div{
width:100px;
height:100px;
overflow:hidden;
}
&lt;/style&gt;
&lt;script type="text/javascript"&gt;
function overFlow(div){
div.style.overflow=div.style.overflow=='auto'?'hidden':'auto';
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table style="width:100px;border:solid 1px #000"&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;div title="click to see more..." onclick="overFlow(this)"&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque dapibus justo eu mi. Mauris lectus. Mauris volutpat adipiscing nisl.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @mr0975 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...