如何设置动态数据的css属性(How to set the css property of dynamic data)
我正在使用javascript在div标签中写一些内容。 数据通过ajax接收。 这是脚本
$.ajax({ url :' the url', data : { productValue: selectedText, giveMyId : saveMyName }, type: 'POST', dataType: 'json', success: function(data) { var imageHTML=''; var dataLength=data.length; photosHasPath=data[0]; if(dataLength > 1) { for(var i=1;i<dataLength;i++) { allProductNames.push(data[i]); imageHTML += '<img src="' + photosHasPath + data[i] + '" height="100" width="100" style="padding: 0.5em;">' + ' <input type=\"button\" class=\"deletePhoto\" value=\"Delete\" name=\"'+data[i]+'\">'; } $('#pastePhotos').html(imageHTML); } else { $('#pastePhotos').html('<i>No photos left.</i>'); } } });
现在我正在尝试设置此div的css属性(具有id“pastePhotos”),其显示为:inline-table 。 但它不起作用。 它显示图像和删除按钮,就像一行中的文本。
题:-
那怎么能为它设置css属性呢?
注意:-
我已经尝试了以下的事情
1。imageHTML += '<img src="' + photosHasPath + data[i] + '" height="100" width="100" style="padding: 0.5em; display: inline-table;">' + ' <input type=\"button\" class=\"deletePhoto\" value=\"Delete\" name=\"'+data[i]+'\">';
2。
'<div style="display: inline-table;">' + imageHtml + '</div>'
3。
<div id="pastePhotos" style="display: inline-table;">
I am using javascript to write some content in a div tag. The data is received through ajax. Here is the script
$.ajax({ url :' the url', data : { productValue: selectedText, giveMyId : saveMyName }, type: 'POST', dataType: 'json', success: function(data) { var imageHTML=''; var dataLength=data.length; photosHasPath=data[0]; if(dataLength > 1) { for(var i=1;i<dataLength;i++) { allProductNames.push(data[i]); imageHTML += '<img src="' + photosHasPath + data[i] + '" height="100" width="100" style="padding: 0.5em;">' + ' <input type=\"button\" class=\"deletePhoto\" value=\"Delete\" name=\"'+data[i]+'\">'; } $('#pastePhotos').html(imageHTML); } else { $('#pastePhotos').html('<i>No photos left.</i>'); } } });
Now I am trying to set the css property of this div (having id 'pastePhotos') which is display:inline-table. But its not working. Its showing the images and the delete button like a text in a single line.
Question:-
SO how can i set the css property for it?
Note:-
I have already tried the following things
1 .imageHTML += '<img src="' + photosHasPath + data[i] + '" height="100" width="100" style="padding: 0.5em; display: inline-table;">' + ' <input type=\"button\" class=\"deletePhoto\" value=\"Delete\" name=\"'+data[i]+'\">';
2 .
'<div style="display: inline-table;">' + imageHtml + '</div>'
3 .
<div id="pastePhotos" style="display: inline-table;">
原文:https://stackoverflow.com/questions/21251627
最满意答案
您可以使用一次调用将任何Swing程序的外观设置设置为本机操作系统。
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
可以在嵌套布局示例中看到Windows PLAF。
You can set the look and feel of any Swing program to the native operating system's with one call.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
The Windows PLAF can be seen in the Nested Layout Example.
相关问答
更多-
您可以使用一次调用将任何Swing程序的外观设置设置为本机操作系统。 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) 可以在嵌套布局示例中看到Windows PLAF。 You can set the look and feel of any Swing program to the native operating system's with one call. UIManager.setLookAndFeel(UIM ...
-
它失败是因为您在C:\Program Files\R安装了R,即使Windows上的R的FAQ告诉您不要在带空格的路径中安装R. 请参阅“问题2.2:如何为Windows安装R”: 如果您希望能够从源构建包,我们建议您选择不包含空格的安装路径。 Rcpp / RInside文档重复了该建议。 不要在带空格的路径中安装R. 如果必须,您必须修复Makefile以避免路径扩展中断。 It fails because you installed R in C:\Program Files\R even thoug ...
-
如何使我的Perl脚本像Windows上的普通程序一样运行?(How do I make my Perl scripts act like normal programs on Windows?)[2021-11-30]
注意:以下操作需要管理权限。 对于使用命令提示符的步骤,必须通过Windows Vista / Windows 7上的“以管理员身份运行”启动。 将* .pl文件与perl关联 在shell提示符下运行以下命令: assoc .pl=PerlScript ftype PerlScript=C:\bin\perl.exe "%1" %* 用Perl安装路径替换C:\Perl\bin\perl.exe 。 这使您可以运行myscript.pl而不是perl myscript.pl 。 默认安装位置为: Act ... -
Raspberry Pi 3上的Windows 10 iot可以运行java程序吗?(Can Windows 10 iot on Raspberry Pi 3 run java program well?)[2022-01-01]
截至今天,没有人将Java移植到Windows IOT用于ARM CPU。 对于其他软件包来说,它看起来同样黯淡。 Java在Linux上的Raspberry Pi上运行得很好,无论如何,它是Raspberry的首选操作系统。 至于原因,在教育之外,没有理智的人会想要使用Windows IOT。 没有商业利益,公司有动力提供支持。 微软似乎在营销WindowsIOT上投入更多资金,然后实际投资于软件。 As of today nobody has ported Java to Windows IOT for ... -
实时在线编程竞赛很酷......但有很多方法让它错误。 我记得我们在学校使用过的一个Java漏洞,它具有URL黑客漏洞,文件IO执行漏洞等。我能够添加其他学校的朋友并列出服务器上的文件。 我很惊讶系统还在运行。 正如评论中所提到的,您最好避免任何类型的远程程序执行。 Real-time online programming competitions are cool... but there are many ways to get it wrong. I remember a Java one we us ...
-
为什么必须为Windows和Linux编写单独的程序(Why do you have to write separate Programs for Windows & Linux)[2022-06-30]
从技术上讲,你错了。 Java不能在Linux上运行。 它也不能在Windows上运行。 它既不在Mac上运行,也不在任何其他类Unix操作系统上运行。 就此而言,它不能在任何操作系统上运行。 它直接在机器上运行。 它只适用于一种类型的机器 - Java虚拟机。 幸运的是,Java虚拟机已经虚拟化到Linux,Windows,Mac等。 Technically you are wrong. Java does not run on Linux. It also does not run on Windows ... -
实现所需(安全)的唯一方法是使用某种虚拟化技术在隔离的vms(例如virtualbox和vmware)中启动这些程序。 如注释中所述,java SecurityManager不会保护在java vm之外运行的任何代码。 The only way to do what you want (securely) is to use some sort of virtualization technology to launch these programs in isolated vms (e.g. virtua ...
-
使用Windows命令行在Java中使用软件包编译程序(Compiling programs with packages in java using windows command line)[2024-04-07]
像桌面一样运行它, c:/.../Desktop> java Mypack.file_name run it as likewise from Desktop, c:/.../Desktop> java Mypack.file_name -
C和C ++:cl Java:javac Python:python或pythonw VB:vbc C#:csc Ruby:红宝石 C and C++: cl Java: javac Python: python or pythonw VB: vbc C#: csc Ruby: ruby
-
Java中有两种类型的UI组件:重量级和轻量级。 重量级组件是操作系统中存在的东西的包装器。 Windows作为操作系统具有创建窗口,对话框等的方法。 使用2D绘图API等完全在应用程序内创建一个轻量级组件。 操作系统对此一无所知。 这两个“官方”Java GUI API是Swing和AWT。 小程序通常使用AWT(无论如何,早期的)。 它由重量级组件组成。 Swing是建立在AWT的基础之上的,但它是用于设计通常桌面应用程序的更广泛的API。 大多数Swing组件都是轻量级的。 因此,Java桌面应用程序 ...