3
화면에 텍스트를 표시하고이를 클릭하면 jquery를 사용하여 텍스트를 편집 할 수 있습니다.
하지만 편집 한 텍스트를 기본값으로 재설정하고 데이터베이스에 텍스트를 제출하는 방법을 모르겠습니다. 누군가가 저를 도우십시오 알고있는 경우에, 미리 감사하십시오.jquery를 사용하여 데이터베이스에 텍스트 전달
jQuery.fn.extend({
live: function (event, callback) {
if (this.selector) {
jQuery(document).on(event, this.selector, callback);
}
}
});
$(document).on('click', '.cmtedit', function (e) {
console.log(this);
TBox(this);
});
$("input").live('blur', function (e) {
RBox(this);
});
function TBox(obj) {
var id = $(obj).attr("id");
var tid = id.replace("cmt_edit_", "cmt_tedit_");
var input = $('<input />', { 'type': 'text', 'name': 'n' + tid, 'id': tid, 'class': 'text_box', 'value': $(obj).html() });
$(obj).parent().append(input);
$(obj).remove();
input.focus();
}
function RBox(obj) {
var id = $(obj).attr("id");
var tid = id.replace("cmt_tedit_", "cmt_edit_");
var input = $('<p />', { 'id': tid, 'class': 'cmtedit', 'html': $(obj).val() });
$(obj).parent().append(input);
$(obj).remove();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<div id="sample">
<p id="cmt_edit_323" class="cmtedit">Sample Text</p>
</div>
<div>
<button type="reset" class="btn btn-primary">Reset</button>
<button type="submit" class="btn btn-success" name="subtn">Submit</button>
</div>
</form>
이 코드가 작동 기능 추가 그 이전 값을 몇 가지 변수를 이전 값은 다시 그 때는이 저장소를 클릭하십시오! 감사합니다 , 단추 작업을 제출하는 방법을 알 수 있습니까? –
@QiuXue'form'에서'action' (*'action = "rediect.php"'*) 속성을 언급해야합니다. [이 기사를 보시려면] (https://www.w3schools.com/html/html_forms .asp) 도움이 당신의 목표를 찾으십시오 – prasanth
고마워요! 당신은 정말로 내 질문을 해결합니다 –