admin管理员组

文章数量:1313091

have not been able to get this property show up in the DOM via jquery or native javascript. jquery doesn't seem to support it and I can't find a native name/syntax that works. Any help??

have not been able to get this property show up in the DOM via jquery or native javascript. jquery doesn't seem to support it and I can't find a native name/syntax that works. Any help??

Share Improve this question edited May 15, 2017 at 20:33 cweiske 31.1k15 gold badges147 silver badges205 bronze badges asked Jun 26, 2012 at 19:24 tuddytuddy 1,8344 gold badges31 silver badges36 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

The correct syntax is

el.style.WebkitOverflowScrolling = 'touch'; // capital W

This is going (nearly) like the usual naming convention from css to JS like border-top is being borderTop, ... just that the webkit stuff gets a capical first letter.

With JavaScript, you need to replace dash - with following capital letter, example:

var el = document.getElementById('element id');
el.style.webkitOverflowScrolling = 'touch';

When using the style property within JavaScript, capitalize letters following dash, so -webkit-overflow-scrolling bees WebkitOverflowScrolling and make sure to also set overflow to scroll.

Try it here: http://jsbin./civaha

You can tell it is touch scrolling because of the bounce.

Source:

<!doctype html>
<meta name=viewport content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<title>set touch scrolling in JavaScript - robocat</title>

<script>
function makeScrollable(event) {
    var style = event.target.style;
    style.overflow = 'scroll';
    style.WebkitOverflowScrolling = 'touch'; 
    style.backgroundColor = 'lightyellow';
}
</script>

<body style="margin:0;overflow:hidden;">

<h3>The div below can't scroll until you tap it and it turns yellow, then it can scroll horizontally. . . . </h3>

<div onclick="makeScrollable(event)" style="background-color:lightblue;white-space:nowrap;padding:30px 0;font-size:150%;width:100%;overflow:hidden;">
        Shu' thi gob where there's muck there's brass a pint 'o mild. Be reet will 'e 'eckerslike by 'eck chuffin' nora that's champion. What's that when it's at ooam god's own county. Tha knows nay lad. What's that when it's at ooam. T'foot o' our stairs ah'll box thi ears sup wi' 'im tha daft apeth ah'll gi' thi summat to rooer abaht. Th'art nesh thee ne'ermind. Eeh. How much ah'll gi' thi summat to rooer abaht where's tha bin ne'ermind. How much gerritetten nobbut a lad. Face like a slapped arse bobbar cack-handed. God's own county wacken thi sen up dahn t'coil oil by 'eck dahn t'coil oil th'art nesh thee. A pint 'o mild. T'foot o' our stairs tell thi summat for nowt mardy bum where there's muck there's brass. Chuffin' nora. Sup wi' 'im sup wi' 'im nah then. Dahn t'coil oil tha what will 'e 'eckerslike ah'll learn thi. A pint 'o mild chuffin' nora tha daft apeth shurrup michael palin. Ah'll gi' thi summat to rooer abaht tha what nah then tha knows. Dahn t'coil oil breadcake where's tha bin eeh. Breadcake how much. Bobbar be reet soft southern pansy. Is that thine. God's own county shu' thi gob mardy bum a pint 'o mild. Soft southern pansy breadcake a pint 'o mild.
</div>

本文标签: iosAny way to apply 39webkitoverflowscrolling touch39 inline with javascriptStack Overflow