将jquery正则表达式匹配中的匹配值分配给字符串变量(assign matched values from jquery regex match to string variable)
我做错了。 我知道。
我想将匹配的文本作为正则表达式的结果分配给字符串var。
基本上正则表达式应该在两个冒号之间拉出任何东西
所以, 等等:xx:blahdeeblah会导致xx
var matchedString= $(current).match('[^.:]+):(.*?):([^.:]+'); alert(matchedString);
我希望得到这个把xx放在我的matchString变量中。
我检查了jquery文档,他们说匹配应该返回一个数组。 (字符串char数组?)
当我运行时没有任何反应,控制台中没有错误,但我测试了正则表达式,它在js之外工作。 我开始认为我只是在做正则表达式错误,或者我完全没有得到匹配函数如何完全正常工作
I am doing it wrong. I know.
I want to assign the matched text that is the result of a regex to a string var.
basically the regex is supposed to pull out anything in between two colons
so blah:xx:blahdeeblah would result in xx
var matchedString= $(current).match('[^.:]+):(.*?):([^.:]+'); alert(matchedString);
I am looking to get this to put the xx in my matchedString variable.
I checked the jquery docs and they say that match should return an array. (string char array?)
When I run this nothing happens, No errors in the console but I tested the regex and it works outside of js. I am starting to think I am just doing the regex wrong or I am completely not getting how the match function works altogether
原文:https://stackoverflow.com/questions/3101546
最满意答案
正如我在这里所说的那样,对我来说并不完美,但它很接近。 我不得不拿出底部:0; 从我添加的新容器中将其换成顶部:80%!重要; 代码如下所示:
resize.js:
$(function() { var resize_container = $("<span />", {class: "resize_container"}); var container = $("<ul />", { class: "container_t" }); container.resizable({ handles: "n" }); var header = $("<li />", { class: "header_t" }); var content_container = $("<li />", { class: "content_container_t" }); container.append(header); container.append(content_container); resize_container.append(container); $('body').append(resize_container); });
style.css中:
.resize_container { position: fixed !important; top: 79% !important; left: 0px !important; } .container_t { list-style: none; bottom: 0px; left: 0px; width: 350px; height: 150px; background-color: red; padding: 0; margin: 0; box-sizing: border-box; } .header_t { width: 100%; height: 35px; background-color: blue; padding: 5px; box-sizing: border-box; } .content_container_t { width: 100%; height: 70%; background-color: green; padding: 5px; box-sizing: border-box; } .ui-resizable-n { cursor: n-resize; border-top: 5px solid purple; } ui-resizable-e { cursor: e-resize; border-right: 5px solid purple; }
As I said the solution here, wasn't perfect for me, but it was close. I had to take out bottom: 0; from the new container I added and swapped it for top: 80% !important; The code looks like this:
resize.js:
$(function() { var resize_container = $("<span />", {class: "resize_container"}); var container = $("<ul />", { class: "container_t" }); container.resizable({ handles: "n" }); var header = $("<li />", { class: "header_t" }); var content_container = $("<li />", { class: "content_container_t" }); container.append(header); container.append(content_container); resize_container.append(container); $('body').append(resize_container); });
style.css:
.resize_container { position: fixed !important; top: 79% !important; left: 0px !important; } .container_t { list-style: none; bottom: 0px; left: 0px; width: 350px; height: 150px; background-color: red; padding: 0; margin: 0; box-sizing: border-box; } .header_t { width: 100%; height: 35px; background-color: blue; padding: 5px; box-sizing: border-box; } .content_container_t { width: 100%; height: 70%; background-color: green; padding: 5px; box-sizing: border-box; } .ui-resizable-n { cursor: n-resize; border-top: 5px solid purple; } ui-resizable-e { cursor: e-resize; border-right: 5px solid purple; }
相关问答
更多-
我不知道你是否已经尝试过,但QWidget::setFixedSize应该做你想要的 I don't know if you already tried it, but QWidget::setFixedSize should do what you want
-
jQuery-ui在元素被删除后可以排序的奇怪行为(jQuery-ui weird behavior with sortable after an element is dropped)[2023-03-29]
好吧,这可能不是一个完整的答案(但标记有一个奇怪的“卡体”持卡人,所以我将其重命名为测试。不会像问题中所表示的那样“克隆”...所以它会在我的例如但不知道这完全重现/解决这里。我更新了“克隆”的一部分,但不知道这是你的愿望。 $(document).ready(function() { $('.draggable-element').draggable({ revert: 'invalid', appendTo: '.dropzone', helper: 'clone' ... -
它是可调整大小的 ,不可调整大小。 It's resizable, not resizeable.
-
这可以通过调整transform: scale(1.6)来解决transform: scale(1.6) 。 拖动项目时,它会使用它的position来调整拖动项目的top和left 。 使用scale() ,这些值将关闭,您将看到项目移动移动的速度与鼠标相同。 x1 = x * 1.6; y1 = y * 1.6; 要使用鼠标移动,我们需要将其调整回相同的1:1(而不是1:1.6)比率。 这可以这样做: jQuery> Draggable>拖动选项 drag: function(e, ui) { // ...
-
尝试这个: 工作实例 JS $('li').each(function () { $(this).css({ bottom: $(this).css('height') }); }); CSS li { background-color: red; list-style: none; float:left; margin-right:5px; width: 15px; position:relative; } #sortabl ...
-
正如@John所提到的,看起来你已经将可拖动图像的x和y坐标分别存储在元素#source_x和#source_y中。 您应该能够在另一个函数中访问它们,如下所示: var x =$("#source_x").val(); var y = $("#source_y").val(); 只是一个观察,你的助手属性克隆似乎导致图像在被拖动后重置它的位置。 我怀疑这会覆盖你的坐标值,每次重置为0,0。 尝试: $("#image").draggable({ stop:function(event,ui) { ...
-
正如我在这里所说的那样,对我来说并不完美,但它很接近。 我不得不拿出底部:0; 从我添加的新容器中将其换成顶部:80%!重要; 代码如下所示: resize.js: $(function() { var resize_container = $("", {class: "resize_container"}); var container = $("
-
JQuery-UI ToolTip的位置(JQuery-UI ToolTip position)[2023-01-02]
查看曲目选项。 工具提示是否应跟踪(跟随)鼠标。 Check out the track option. Whether the tooltip should track (follow) the mouse. -
我终于解决了我的问题。 解决方案不是使用对话框的可拖动设置,而是使用小部件本身。 所以我的代码现在看起来像这样: $("#dialog").dialog( { draggable: false, dialogClass: 'my-dialog' } }); $('.my-dialog').draggable({ containment: 'window' }); I finally fixed my problem. The solution was not ...
-
Jquery-ui Autocomplete和Bootstrap 3固定导航栏(Jquery-ui Autocomplete and Bootstrap 3 fixed navbar)[2022-08-19]
将.ui-autocomplete的z-index设置为2000 的jsfiddle Set the z-index of .ui-autocomplete to 2000 JSFiddle