GVKun编程网logo

javascript-jQuery mobile中textarea的高度和宽度?(jquery设置高度和宽度)

19

关于javascript-jQuerymobile中textarea的高度和宽度?和jquery设置高度和宽度的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于javascript–Clic

关于javascript-jQuery mobile中textarea的高度和宽度?jquery设置高度和宽度的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于javascript – Clicks / tap在JQuery Mobile中传递绝对定位的div、javascript – CSS3如何计算尺度后的高度和宽度、javascript – jQuery / JS获取textarea的滚动条高度、javascript – jQuery Mobile Beta:不能再使用$(‘[data-role = header]’)?等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

javascript-jQuery mobile中textarea的高度和宽度?(jquery设置高度和宽度)

javascript-jQuery mobile中textarea的高度和宽度?(jquery设置高度和宽度)

我在jQuery mobile中固定了text-area元素的高度,在人像中获得了完美的高度和宽度,但在横向中宽度没有扩大.谁能帮我?提前致谢.

HTML:        <textarea cols="55" rows="50" name="textarea" id="newMarkCompleteCommentText"></textarea>

IN JS:
    $('#newCommentText').attr('style', 'background-color:White;font-size:18px;height:7em;');

解决方法:

尝试设置“宽度:自动”.另外,可以使用“ .css(‘attribute’,’value’)”代替“ .attr(‘style’,…)”

$('#newCommentText').css('background-color', 'white').css('font-size', '18px').css('height', '7em').css('width', 'auto');

javascript – Clicks / tap在JQuery Mobile中传递绝对定位的div

javascript – Clicks / tap在JQuery Mobile中传递绝对定位的div

我不确定是否有其他人在JQuery Mobile中遇到过这种情况,但出于某种原因,我无法阻止我的绝对定位DIV下面的元素和固定标题来拦截移动设备上的点击/点击.

例如,我有一个页面列出了长滚动列表中的联系人.在该页面上是带有按钮的浮动标题.如果我向下滚动列表并单击浮动标题的按钮,则单击将转到标题下面的任何联系人,即使它无法在视觉上看到,因为它位于标题下方.

如果我单击标题中的按钮,按钮永远不会触发 – 它下面的列表元素始终触发.如果我滚动列表以便标题下面没有任何内容,我可以正常点击标题按钮.

到目前为止,我已经尝试过:
– 标题按钮上的event.stopPropagation().然而,这从未被解雇过.下面的元素总是窃取焦点

>检测点击事件的Y坐标.如果坐标小于浮动标题的高度,则中止单击操作.然而,这也不起作用 – 在我“返回true;”之后,按钮的单击处理程序从未触发.
>在浮动标题和列表项容器上设置z-indexes,即使它们已经在视觉上正确.

我很难过.我试着制作一个测试床,但它在那里工作正常.它也可以在JQM演示站点上正常工作,因此它必须与我的应用程序的CSS或结构有关.我想不出什么会导致浮动元素正确显示,但只有在其他任何东西都没有可用的时候才可以点击.

任何想法,将不胜感激!

最佳答案
通过一个漫长的消除过程来计算出这个. JQM 1.3中引入的新“面板”导致移动设备上固定标头出现问题.对标题的任何点击都会被忽略,就好像标题的z-index低于其下方的z-index,即使它在视觉上位于顶部.

我通过从ui-panel-content-wrap DIV中删除所有类来找到问题

var wrapper = $(".ui-panel-content-wrap");
$(wrapper).removeClass('ui-body-c').removeClass('ui-panel-animate').removeClass('ui-panel-content-wrap-closed').removeClass('ui-panel-content-wrap');

一旦我这样做,它当然打破了面板,但我的固定标题再次可以正确点击.

从那里开始,我重新介绍了每个课程,直到我发现“ui-panel-content-wrap”是罪犯.然后我追溯到这个:

/* hardware acceleration for smoother transitions on WebKit browsers */
.ui-panel-animate.ui-panel:not(.ui-panel-display-reveal),.ui-panel-animate.ui-panel:not(.ui-panel-display-reveal) > div,.ui-panel-animate.ui-panel-closed.ui-panel-display-reveal > div,.ui-panel-animate.ui-panel-content-wrap,.ui-panel-animate.ui-panel-content-fixed-toolbar {
    -webkit-backface-visibility: hidden;
    -webkit-transform: translate3d(0,0);
}

如果你注释掉或覆盖-webkit-transform:translate3d(0,0);固定标题将开始捕获事件.

javascript – CSS3如何计算尺度后的高度和宽度

javascript – CSS3如何计算尺度后的高度和宽度

参见英文答案 > Retrieve width/height of a css3 scaled element4个
有没有可以找到-webkit-transform的精确显示高度的jQuery解决方案:scale(0.7851);

规模值可能会有所不同,这就是为什么寻找正确的解决方案

测试这些选项不幸没有找到解决方案:(

height()
innerHeight()
outerHeight()
outerHeight(true)

我认为这个问题只能解决数学的基础;)

解决方法

使用 getBoundingClientRect().
element.getBoundingClientRect().height

见DEMO.

javascript – jQuery / JS获取textarea的滚动条高度

javascript – jQuery / JS获取textarea的滚动条高度

我有一个固定高度的文本区.当用户在文本区域中键入文本时,用户在其中键入一些文本后会显示一个滚动条.

如何使用jQuery或纯JavaScript获取滚动条高度?我一直在寻找这个几个小时,但找不到任何东西.我不能只插入一个div并通过div偏移得到滚动条高度,因为textarea不允许有子元素.

请不要给我一个jQuery插件的链接.我想学东西

解决方法

textarea.scrollHeight

返回一个整数(像素)

javascript – jQuery Mobile Beta:不能再使用$(‘[data-role = header]’)?

javascript – jQuery Mobile Beta:不能再使用$(‘[data-role = header]’)?

我曾经能够掌握

$('[data-role=header]').first().height()

在使用jQuery 1.5.2的alpha中,但不再可以使用jQuery 1.6.1进行测试.有什么变化?

完整代码 – 这将0写入console.log …

<!DOCTYPE html> 
<html> 
 <head> 
 <title>Page Title</title> 
 <Meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" />
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
 <script type="text/javascript"
  src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() {
 console.log($('[data-role=header]').first().height());
 });
 </script>
</head> 
<body> 
<div data-role="page" id="home">

       <div data-role="header">
       <h1>Header</h1>
       </div>
 <div data-role="content">
         //lots of code
        </div>
 </div>
 </body>
</html>

但是,将其更改为jQuery 1.5.2和jQuery Mobile alpha:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script>

它写入标题div的非零高度.

顺便说一下,它与jQuery 1.6.1也不是零,但没有jQuery Mobile.所以它与jQuery Mobile渲染有关.

在release notes中看不到任何可能发生的事情,但我不是jQuery专家.

解决方法:

看起来他们确实改变了一些语法,Docs:

> http://jquerymobile.com/demos/1.0b1/docs/api/methods.html

When finding elements by their jQuery
Mobile data attribute, please use the
custom selector :jqmData(), as it
automatically incorporates namespaced
data attributes into the lookup when
they are in use. For example, instead
of calling $(“div[data-role=’page’]”),
you should use
$(“div:jqmData(role=’page’)”), which
internally maps to $(“div[data-“+
$.mobile.ns +”role=’page’]”) without
forcing you to concatenate a namespace
into your selectors manually.

试试这个:

$("div:jqmData(role='header')").first().height()

关于javascript-jQuery mobile中textarea的高度和宽度?jquery设置高度和宽度的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于javascript – Clicks / tap在JQuery Mobile中传递绝对定位的div、javascript – CSS3如何计算尺度后的高度和宽度、javascript – jQuery / JS获取textarea的滚动条高度、javascript – jQuery Mobile Beta:不能再使用$(‘[data-role = header]’)?等相关知识的信息别忘了在本站进行查找喔。

本文标签: