我会创建字段textarea,当用户输入html basic到textarea时,结果可以读取html。
代码基本
<form action="">
Name:
<input type="text">
Contents:
<textarea name="contents"></textarea>
</form>
在提交结果 Hello World 时,我将<strong>Hello World</strong>
输入textarea
这就像Wordpress中的Widget Text。
答案 0 :(得分:0)
您希望根据用户输入动态创建html元素。尝试使用JQuery!以下是一个示例:http://jsfiddle.net/ddan/m7jba0uk/1/
HTML:
Thread streamThread = new Thread(new Runnable() {
@Override
public void run() {
try {
int minBufSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat)*10;
log2("Socket Created");
DatagramPacket packet;
final InetAddress destination = InetAddress.getByName("192.168.49.1");
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,sampleRate,AudioFormat.CHANNEL_CONFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT,minBufSize);
log2("Recorder initialized");
byte[] buffer = new byte[1600];
recorder.startRecording();
int bytes_read = 0;
DatagramSocket socket1 = new DatagramSocket();
while(true) {
//reading data from MIC into buffer
bytes_read = recorder.read(buffer, 0, 1600);
//putting buffer in the packet
packet = new DatagramPacket (buffer, bytes_read,destination,9000);
socket1.send(packet);
}
} catch (IOException e) {
//Log.e("VS", "IOException");
}
}
});
streamThread.start();
JS:
<form action="">
Name:
<input type="text"><br>
Contents:
<textarea name="contents"></textarea>
</form>
<input type='button' onclick='doTheThing()' value='Do the thing'>
<div id='result'></div>
尝试输入function doTheThing() {
$('#result').append($('textarea[name="contents"]').val());
}
我希望它有助于实现你的想法。